Can't install external packages in Python - python-2.7

My problem is when I'm trying to install an external package via Command Prompt, I'm getting an error. I've just started programming and I don't understand everything yet.
That's an error:

If Python 2 and Python 3 are both installed on the system, they can interfere and cause easy_install to break.
Hence, you will need to specify which version of Python and easy_install you want, like this:
python-2.7 -m easy_install <module>
For any other version of Python, just change the -2.7 to your major.minor version.

Related

Installing NumPy + SciPy in Python 2.7 now fails with "RuntimeError: Python version >= 3.5 required"

Installing numpy and scipy from source like this (say, in a fresh Python 2.7 pyenv virtualenv):
pip install numpy==1.14.6 scipy==1.0.1 --no-binary numpy,scipy
gets their installers to use a ~/.numpy-site.cfg file that points to my openblas installation.
This used to work. Now it produces a long stack trace ending with:
File "/usr/local/var/pyenv/versions/2.7.16/envs/issue/lib/python2.7/site-packages/setuptools/sandbox.py", line 45, in _execfile
exec(code, globals, locals)
File "/var/folders/_b/q30qg_l50b5gvqd8y4_wb9h00000gn/T/easy_install-o9MJ5E/numpy-1.17.1/setup.py", line 31, in <module>
if sys.version_info[0] < 3:
RuntimeError: Python version >= 3.5 required.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Q. What changed?
Q. Why does it say Python version >= 3.5 required. in a Python 2.7 installation?
Q. How to fix it?
The scipy 1.0.1 installer requires numpy as a prerequisite, but the multiple installers working together end up getting the latest version of numpy unless numpy is already present.
What changed: The latest version of numpy requires Python 3.5+, hence the error message.
So even though the pip command explicitly asked to install numpy==1.14.6 scipy==1.0.1, it triggers a newer numpy installer that fails on Python 2. (The last entry in the stack trace shows numpy-1.17.1 requiring Python 3.)
The problem arises in the interaction between pip, the scipy and numpy installers, and easy_install. Details in pip issue #6945.
Workaround: Install numpy first. Then install scipy. Alternatively, the one-line install might work if you don't need the --no-binary option.
I also encountered an issue where scipy was been installed through a script and it was trying to install a version 1.7.1 which required python 3.7 at least and i hand 3.6. The workaround was i installed scipy myself and the version i got was 1.5.4.

pip install for whl files

I am trying to install scipy package for python 2.7 in windows,
The process i followed is as follows:
downloaded a whl file scipy-0.17.1-cp27-cp27m-win32.whl from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
tried to install by
pip install scipy-0.17.1-cp27-cp27m-win32.whl
error : Requirement 'scipy-0.15.1-cp27-none-win32.whl' looks like
a filename but the file does not exist
scipy-0.15.1-cp27-none-win32.whl is not a supported wheelon this platform.
then tried to install by
pip install file_location\scipy-0.17.1-cp27-cp27m-win32.whl.
error displayed :scipy-0.15.1-cp27-none-win32.whl is not a supported wheel on this platform.
Also i have already upgraded my pip command.
Can anyone suggest me out some valid solutions?
I Think the issue in Python interpreter variant 32 or 64.. if your python is 32-bit then use scipy-0.17.1-cp27-cp27m-win32.whl otherwise if your python is 64Bit then try scipy-0.17.1-cp27-cp27m-win_amd64.whl

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

Windows 7 virtualenv envl AssertionError and OSError

AssertionError: C:\Python27\lib\site-packages\virtualenv-1.11-py2.7.egg\EGG-INFO\PKG-INFO is not a subpath of C:\Python27\lib\site-packages\virtualenv-1.11-py2.7.egg\virtualenv_support\setuptools-2.0.2-py2.py3-none-any.whl\
OSError: Command D:\myproject2\envl\Scripts\python.exe -c "import sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip failed with error code 1
How can I fix the AssertionError and OSError?
I tried "activate", but it doesn't work.
I know activate.bat file didn't exist...
I think it is because of these errors.
I just ran into this today. Although not possibly the best answer, here's what I did:
Completely uninstalled all previous Python versions. (I had 64bit versions of both 2.7 and 3.2 already installed, plus a 32bit version of 2.7)
Removed any remaining files in the python install path(s).
Restarted. (Just in case)
Re-installed python.
Followed the non-chocolatey version of https://zignar.net/2012/06/17/install-python-on-windows/ exactly. (aka I didn't install pip via easy_install, but instead downloaded the get-pip.py file as explained in the guide)
Run which virtualenv to check that virtualenv is installed and being pulled from the correct location. (If not, add the path to you python install to you PATH environment variable, removing any other python paths)
Now when I try virtualenv --no-site-packages <packagename>, it works!

Problems upgrading to Python 3.3 and setting up Django

I'm new to Linux and am trying to set up Python / Django on my machine! I installed Python 3.3 from the source file and it was compiled into /usr/local/bin. Then I created a symbolic link between /usr/bin/python and /usr/local/bin/python3, so that whenever I invoke python from the command line it uses the latest version.
Now I am trying to install MySQL Python and I got the following output:
apt-get install python-mysqldb
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-mysqldb is already the newest version.
The following extra packages will be installed:
apt-listchanges python-apt
Suggested packages:
python-glade2 python-gtk2 python-apt-dbg python-vte python-apt-doc
The following packages will be upgraded:
apt-listchanges python-apt
2 upgraded, 0 newly installed, 0 to remove and 142 not upgraded.
3 not fully installed or removed.
Need to get 0 B/394 kB of archives.
After this operation, 250 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Traceback (most recent call last):
File "/usr/bin/apt-listchanges", line 28, in <module>
import apt_pkg
ImportError: No module named 'apt_pkg'
Any ideas on how to fix this? Or any tips on how to clean up this install (if this one is too broken)?
Re-installing Python (apt-get install --reinstall python) should fix your installation issue.
Note that your approach will result in a lot of brokenness. Changing system Python version involves far than just changing symlinks, which is why you should leave it to the distro makers (see a similar question).
One other fact is that Debian already packages 3.3 (currently in Experimental), so rather install that. I just don't know if the system Python modules (e.g. python-apt) will work with it. If not, just use 3.2.
One other thing, if you want to use python-mysqldb, you have to stick to Python 2, because it will not run with Python 3. If you insist on Python 3, use python3-mysql.connector.