I'm trying to install 'pymorph' on mac os x with 'PIP':
sudo pip install pymorph
I'm getting the following error:
NameError: name 'execfile' is not defined
Command "python setup.py egg_info" failed with error code 1 in
/private/tmp/pip-build-9hjd5tfm/pymorph/
I have read that using a python version different from 2.7 could lead to this kind of problem. Yet, I'm using the 2.7 version:
python --version
Python 2.7.13
Any ideas to solve this issue ?
Thank you in advance
It's possible to have a pip command on your PATH that comes from a different Python installation than the python command. (Each entry script to a Python-based tool is bound to the Python installation that was used to install the package that provided it. This means that the pip command does not search PATH for a python installation.) If this pip comes up later on PATH than python, it would lead to behaviour that you describe.
This can happen, say, if you first install a Python 2.7 without pip, and then a Python 3.x with pip, if the installers prepend to PATH.
You can verify which version of Python pip is using and where it's installed by running pip -V.
The robust solution to this should be using a virtual environment that lets you tie the base python installation and libraries specific to your application alone with your project, as well as avoid cluttering your global site-packages, and prevent inadvertent compatibility issues from different versions of the same package being needed by different projects.
It seems that the current (as of late 2017) recommended virtual environment solution is Pipenv. A decent-looking introduction to virtual environments using Pipenv, by the author of Pipenv, can be found here.
Related
I'm quite new to Ubuntu. On my machine, running Ubuntu 20.04 with Python 3.8, I'm trying to run a program which does not support Python 3.8, but it requires Python 3.7 (FYI, it is Carla Simulator).
I need pygame, but when installing it through pip (python3.7 -m pip install pygame) it raises an error:
ModuleNotFoundError: No module named 'distutils.util'
Now, I have distutils correctly installed and updated at version 3.8.2-1ubuntu1.
Is there any way for me to install a distutils version compatible with Python 3.7 without affecting Python 3.8 and related modules? Or do you have hany suggestion to get pygame for Python 3.7 and running Carla somehow? Could a virtual environment help?
My question is really similar to this one How to install python-distutils but I don't actually require distutils, I just need the program to work...
Thank you
----- EDIT -----
I tried creating a virtual environment using venv, but I got an error due tue unavailability of ensurepip. Googling it, I found it might be related to the fact that my Python 3.7 version might have been installed through Anaconda (I actually can't remember). Running apt-cache rdepends python3.7 I get:
python3.7
Reverse Depends:
python3.7-minimal
Is it safe to completely uninstall current Python3.7 and reinstall it to hopefully get ensurepip? Any suggested code to safely do it?
The easiest solution for you would be to run your program in a virtual environment where you would specify the default python version to be 3.7 I think (see Use different Python version with virtualenv for an example). You can then install all your dependencies inside this environment and not have to deal with any conflicts between the two versions on Python.
Using pyenv you could specify the python version you want to use.
for example:
create a new folder and hit:
pyenv local 3.7.2
then create your virtual env by using pipenv:
pipenv install
then start your journey to building your game.
hope it help.
This is probably a really dumb question but I am stuck and wasting too much time on this so I would SO appreciate any help.
I am using a RHEL 7 box and installed Apache Zeppelin on it. Everything works except for the life of me I can't import Python packages such as Pandas.
I realized I didn't have PIP so I installed it with these steps: https://pip.pypa.io/en/stable/installing/ (notice I had to use the "--user" argument for the command "python get-pip.py").
Finally, I did "pip install pandas --user" which worked perfectly. I then go into my Zeppelin notebook and I cannot import pandas, even after restarting the Python interpreter.
I did some research and I think the problem is that "which python" and "which pip" are installed in different directories as the former results in "/usr/bin/python" while the latter in "~/.local/bin/pip".
So I suspect the packages installed with pip are basically getting loaded into a different version of python? If it helps, when I do "whereis python" I get 5 different results such as "/usr/bin/python" and "/usr/bin/python2.7" etc.
First thing to understand is: Python packages aren't installed globally, every installed Python has its own set of packages. BTW, pip being a Python package with a script is also not global. If you have a few different pythons you need different pips for them. I don't know Apache Zeppelin so I cannot guess if it uses the system Python (/usr/bin/python) or has its own Python; in the latter case you need to install pip specifically for Zeppelin so its pip install packages available for Zeppelin.
To investigate to what Python pip installs packages you need to find out under what python it runs. Start with shebang:
head -1 `which pip`
The command will prints something like ~/.local/bin/python. If it's not the version of Python you need to install packages for you need to install a different pip using that Python.
The most complex case would be if the shebang is PATH-dependent, something like #!/usr/bin/env python. In that case pip runs Python that you can find with which python.
PS. AFAIK the simplest way to install pip at RedHat is dnf install python-pip.
phd's answer was very helpful but I found that it was just a matter of using the root account to install the python packages. Then my Zeppelin was able to see any packages.
I've been having a lot of trouble with getting virtualenv to work.
First I installed it via pip and then tried setting up a virtualenv. That didn't work and I got this error message:
ResNets-iMac:desktop zachary$ virtualenv anothertest
Using base prefix '/Applications/Canopy.app/appdata/canopy-1.5.1.2730.macosx-x86_64/Canopy.app/Contents'
New python executable in anothertest/bin/python
dyld: Library not loaded: #rpath/Python
Referenced from: /Users/zachary/Desktop/anothertest/bin/python
Reason: image not found
ERROR: The executable anothertest/bin/python is not functioning
ERROR: It thinks sys.prefix is u'/Users/zachary/Desktop' (should be u'/Users/zachary/Desktop/anothertest')
ERROR: virtualenv is not compatible with this system or executable
So then I went through just about all of the troubleshooting I could and decided that Canopy was the problem. So I deleted that, reinstalled virualenv (via 'pip uninstall virtualenv' then 'pip install virtualenv') and now I am getting this error whenever I try to do anything involving virtualenv:
dyld: Library not loaded: #rpath/Python
Referenced from: /Users/zachary/Library/Enthought/Canopy_64bit/User/bin/python
Reason: image not found
I'm not sure what to do and when I check what my default version of python is, I get:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
I very new at all of this and I don't really have any idea what I have been doing or how to fix this so any help would be greatly appreciated.
Thanks!
The problem is you have multiple versions of Python on your system.
You have the Python that ships with OSX (/Library/Frameworks/Python.framework/Versions/2.7/bin/python), then you have the Python that comes with Canopy; which is /Users/zachary/Library/Enthought/Canopy_64bit/User/bin/python.
Your path is pointing the default version to the one from Canopy, yet pip is installed against the default system version of Python.
So when you installed virtualenv, it was installed against the default version of Python; but when you try to create a virtual environment - due to the way your path are setup, it is trying to use the Canopy version of Python - and that's the source of your error.
To solve this problem you can do any of the following:
Remove Canopy, and use the OSX version of Python.
Install virtualenv on the Canopy version of Python.
Modify your PATH so that the system version of Python takes precedence.
Install another version of Python (from say, homebrew) and make that the default.
The resolution you chose will depend on what you need the system to do. If you need the libraries bundled with Canopy, then you need to choose option #2, otherwise pick any of the other options. #4 is the most disruptive (as it will involve installing a lot of other stuff).
The Enthought Canopy website recommends this: to use venv, and not virtualenv.
I am trying to install pandas via pip install pandas but when I do, I get the error:
Command python setup.py egg_info failed with error code 1 in
c:\users[username]\appdata\local\temp\pip_build_[username]\pandas
I followed the answer given here and installed ez_setup.py without incident, but still get the error when doing pip install pandas.
Thanks for any help, if I can provide more information please let me know.
The easiest way to install pandas and its dependencies on Windows is to download the relevant packages from Christoph Gohlke's Python Extension Packages for Windows repository. You'll find the files for pandas here as well as a list of other required dependencies.
On Linux (Debian / Ubuntu varieties), when NOT installing inside a virtual environment, but in the main system, I find it best to just use the Synaptic Package Manager (because even the --user switch seems to fail when trying to install pandas without sudo). Search for pandas inside Synaptic PM. There's varieties for python 2 and 3.
However, on linux, I have generally found the cleanest, easiest, and overall safest approach to be creating virtual environments and then use pip install <package name> inside the virtual environment. I believe this would be best on Windows too.
I installed Pandas package following procedure listed after the following disclaimer section:
Disclaimer:
- I don't consider myself a computer expert so follow the instructions at your own risk.
- My procedure worked on my windows computer
- My windows computer has python 2.7 installed from python.org
- My python GUI is IDLE
- I don't recall installing pip, it is possible that it installs at the time of installing python 2.7 from python.org (not sure)
- The directory in which my pip.exe is located is under C:\Python27\Scripts
Procedure:
Open a command window for the directory under which you have pip.exe, (in my case is Scripts). The prompt looks like this in my case: C:\Python27\Scripts>
At the prompt type pip install pandas. The prompt looks like this in my case: C:\Python27\Scripts>pip install pandas
Press ENTER key. You should see message: "Collecting pandas" being displayed in the command window.
Once the system completes collecting pandas, you should see message "Successfully installed pandas-0.22.0" , or similar depending on version collected.
Picture shows steps 1 -4 as shown in my computer command window.collecting_pandas
I'm using ubuntu 12.10 with default python3.2. However I downloaded python 3.3 as its much more polished. Of course, since then I have a nightmare with installing modules for 3.3, as python3 packages from synaptic install to 3.2 dir. So, I installed pip using python 3.3. Now I have pip-3.3 command, great. But, when I tried "sudo pip-3.3 install PySide" I quickly got an error: "error: Failed to locate the Python library /usr/lib/libpython3.3m.so". What's more, when I run "sudo pip install PySide" (command for 2.7), it builded and installed and runs flawlessy. Pyvenv and virtualenv both fail too. But I wan't to do it non-env way,just install pyside to global 3.3 lib dir.
So how can I install that PySide to python 3.3? I just can't get it to work... It looks like I will have to stick with default ubuntu python 3 version (this one runs great, everything works both from pip and synaptic), but I like to use newest python as it gets better and better with every release.
Btw, if that matters I also got following warning before that error:
"package init file 'PySide/init.py' not found (or not a regular file)" and
"package init file 'pysideuic/init.py' not found (or not a regular file)"
Edit: I installed full python3.3 from synaptic, including pythoh3.3-dev, debug, lib etc. Everything.
And that dynamic python 3.3 lib exist in /usr/lib/x86_64-linux-gnu/libpython3.3m.so, maybe just python3.3 package for ubuntu is poor and installs it in wrong direction/doesn't do any symlinks tricks?
Please try this answer installing from source (PySide). Download pyside sources and install from source, follow the instructions on the link.