How to install python2.7 specific packages on Arch Linux? - python-2.7

I am building an Arch Linux system from scratch, and presently there is no Python in the system. I could install Python2.7 by using this command:
pacman -S python2
But when I try to install some package for python like this:
pacman -S python-numpy
Pacman only shows option to download Python3.x and numpy for Python3.x. There is no other option available. How can I make sure that when I search for Python stuff, it only searches based on which Python version I have installed? There is no Python3 in my system and I have no need of it at all. In my Ubuntu system, I do not specify the Python version but it is always taken care of. I have no clue how to handle this in Arch Linux.
Thanks in advance!

In Arch Linux the default Python version is 3, so all python-* packages (including python itself) are for Python3. Fortunately Python2 is still fully supported, they are just prefixed with python2-* instead. So to install numpy you would do pacman -S python2-numpy.

Also if you want to download the packages specific to python2.7 from Python Package Index you'll have to use pip2.
e.g.:
sudo pip2 install <package name>

Related

Does tensorflow need GPU

I am trying to install TensorFlow on Linux, Ubuntu 18.10 by following these instructions: https://www.tensorflow.org/install/
I am using python 2.7
I first tried to install it using the pip package and after:
pip install --user --upgrade tensorflow # install in $HOME
I got a message to say that tensorflow 1.12.0 was successfully installed, however when I did the next line:
python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
I got the error
The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine
I then tried to build from source and it failed when I tried to checkout the current branch
bazel test -c opt -- //tensorflow/... -//tensorflow/compiler/... -//tensorflow/lite/...
I skipped the GPU steps as this said optional but am wondering if it is needed?
Not 100% certain what you have going on but in short no Tensorflow does not require a GPU and you shouldn't have to build it from source unless you just feel like it.
Might I suggest you try uninstalling whatever version of Tenforflow you might have, and then reinstall it.
# Try both of these just to be safe
pip uninstall tensorflow
pip uninstall tensorflow-gpu
# I recommend using conda when possible
conda install tensorflow
# but if you don't have conda then pip will work just fine
pip install tensorflow
The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine
Of note that this is a warning only and would not stop TF from running proprely.
TF version you can install from PIP is compiled to be usable on a broad range of systems, but TF can be compiled with system-specific optimizations from source. This warning is intended to remind you of it.
See also https://github.com/tensorflow/tensorflow/issues/7778

Installing Homebrew Python and linking

I need to use the Homebrew version of Python rather than the system version of Python. I have a clean install of macOS Sierra (10.12.5).
I first installed homebrew and then updated ~/.bash_profile using nano ~/.bash_profile.
Then I added this into the file:
# Homebrew
export PATH=/usr/local/bin:$PATH
Then, I needed to manually source the ~/.bash_profile file to ensure the changes have been reloaded using source ~/.bash_profile.
I installed python using brew install python and tried to link using brew linkapps python
The output was this:
Warning: Already linked: /usr/local/Cellar/python/2.7.13_1
To relink: brew unlink python && brew link python
Gautams-Air:~ gautam$ which python
/usr/bin/python
Gautams-Air:~ gautam$ python -V
Python 2.7.10
Gautams-Air:~ gautam$ brew linkapps python
Warning: brew linkapps has been deprecated and will eventually be removed!
Unfortunately brew linkapps cannot behave nicely with e.g. Spotlight using
either aliases or symlinks and Homebrew formulae do not build "proper" .app
bundles that can be relocated. Instead, please consider using brew cask and
migrate formulae using .app's to casks.
Linking: /usr/local/opt/python/IDLE.app
Linking: /usr/local/opt/python/Python Launcher.app
Linked 2 apps to /Applications`
Using which python the output was:
/usr/bin/python
It should have been: /usr/local/bin/python
I also tried using: brew unlink python && brew link python
Also using python -V it shows Python 2.7.10 although the current version in Homebrew is Python 2.7.13
How do I use the Homebrew version of Python instead of the system version of Python? - How do I do the linking?
USING:
macOS Sierra (10.12.5)
Due to a recent change in the Homebrew formula for python2 starting with version 2.7.13_1, Homebrew no longer creates a symlink for python to the Homebrew version.
Instead, it only installs and symlinks python2. You will need to take an additional step to use it instead of the system version of Python.
See the "Caveats" section in this package's info. Below is an example, but note that the actual PATH to export is generated and may be different on your machine.
$ brew info python2
... snip ...
=> Caveats
This formula installs a python2 executable to /usr/local/bin.
If you wish to have this formula's python executable in your PATH then add
the following to ~/.bash_profile:
export PATH="<... some path ...>:$PATH"
... snip ...
Edit: Homebrew talked more about this change in their recent release notes.

Python (Win 10): Installing matplotlib requires packages "freetype" and "png"?

I've been trying to install Python's matplotlib library for use with PyPlot, for use with Julia. I managed to get everything in place except for this one final library, and I feel as though I've hit a deadend trying to get it working.
When trying to install matplotlib (I've attempted using pip, regular python install, and easy_install), I get the following message at the very end of the install output, after which it is NOT installed:
* The following required packages can not be built:
* freetype, png
Confused about this, I looked around online and installed both of these (at least, what I think these were). One was the freetype project, and the other was LibPng, which was the closest thing I could find to a "png package" for windows or python in general.
This didn't initially work (for either of them), and I read somewhere that I needed a freetype.dll in my system32 folder. It was a long shot, but I went to where I installed freetype and pulled out the dll and renamed it, placing it in system32. This of course did not work (again, long shot).
Anyway, that's where I'm at. No idea where to go from here, and I'm unsure if I even grabbed the correct "packages" I should be using. Thoughts?
Use a more powerful installer
I would recommend to use Anaconda or Miniconda. In my experience with many Windows users, this is the simplest way to install packages such as matplotlib.
Anaconda
Anaconda comes with many packages for scientists. Matplotlib works out of the box. Just install as user not root.
Minoconda
If you don't want all packages of Ananconda use Miniconda
Conda
Both ways of installation (Anaconda or Miniconda) provide conda. It is an improved pip/virtualenv.
You can install matplotilb with this command:
conda install matplotlib
Enviroments:
You can create a new environment and install the packages you like:
conda create -n my_project35 python=3.5
activate my_project35
conda install matplotlib
or
conda create -n my_project27 python=2.7
activate my_project27
conda install matplotlib
Combine with pip
You can still use pip. conda "understands" what it is doing.
One snake is enough!
[This is for folks using the Linux Bash Shell on Windows 10.]
If you don't want to go the Anaconda route, you can install freetype (and png) by executing the following in the Windows 10 Bash shell:
sudo apt-get install freetype6-dev
The above command will also automatically install libpng. However, due to an error, the system will not 'realize' it has installed freetype, so you'll need to manually install pkg-config:
sudo apt-get install pkg-config
Thereafter you should be able to install matplotlib via pip without further incident.
sudo pip install matplotlib
I tired downloading matplotlib 2.2.2 with python 3.9.5, getting freetype & png errors for hours.
After downloading python 3.7.9 and removing python 3.9.5 from environment variables, installing matplotlib 2.2.2 worked with no problems!
Change your Python Version
Go to https://www.python.org/downloads/windows/, control-f search 3.7.9 and use the webinstaller. Follow all the recommended instructions
In pyvenv.cfg in your project directory switch version number to 3.7.9 and home to C:.....\Python37.
pip3 install alpaca-backtrader-api

install python pygame on ubuntu 14.10

I want to install pygame library on Ubunbu 14.10. I am using Python 2.7.x. At this time I found dependences problems with python-numpy dependence., because it uses a previous version of gcc that 14.10 uses that's why I am stuck with this, my question is: is there any way to install pygame on 14.10?
best
If you open up the terminal
type in
sudo apt-get install python-pygame
It should download and install the dependencies required for pygame.

How to use -pip- to install packages that can work with Anaconda?

I am trying to install some additional packages that do not come with Anaconda. All of these packages can be installed using pip install PackageName. However, when I type this command at the Anaconda Command Prompt, I get the following error:
Fatal error in launcher: Unable to create process using '"C:\Python27\python.exe
" "C:\python27\scripts\pip.exe" install MechanicalSoup'
I also tried to run the command from the python interpreter after import pip but that also did not work (I got a SyntaxError: invalid syntax).
I am a noob and understand that this might be a very basic question so thanks for your help in advance!
PS: I am using Windows 7, 64 bit, conda version: 3.7.1 and python version: 2.7.6.
When installing anaconda, you are asked if you want to include the installed python to your system PATH variable. Make sure you have it in your PATH. If everything is set up correct, you can run pip from your regular command prompt aswell.
Using #heinzchr's and #mmann's suggestions I was able to piece together the problem. I already had a version of Python 2.7 saved at C:\Python27 and I had to remove this from the Path (My Computer's properties> Advanced system settings> System variables> Path). I can now use pip install from the command line.
There is a way around the use of pip
From the anaconda terminal window you can run:
conda install PackageName
Because MechanicalSoup isn't in one of anaconda's package channels you will have to do a bit of editing
See instructions near the bottom on their blog
For those looking for Python packages not added to current channels in anaconda, try https://conda-forge.org/ For example, if you want to install MechanicalSoup you'll find it at https://anaconda.org/conda-forge/mechanicalsoup and use the -c option to tell conda the channel to use:
conda install -c conda-forge mechanicalsoup