I have an Academic license with Enthought Python Distribution, and I'm getting a strange error when I try to run ipython. Here is some of the behavior I'm seeing:
$ ipython
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/Current/bin/ipython", line 8, in <module>
from IPython import start_ipython
ImportError: cannot import name start_ipython
$ python
Enthought Python Distribution -- www.enthought.com
Version: 7.3-2 (64-bit)
Python 2.7.2 |EPD 7.3-2 (64-bit)| (default, Sep 7 2011, 16:31:15)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "credits", "demo" or "enthought" for more information.
>>> import IPython
>>> IPython.start_ipython()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'start_ipython'
>>>
When I run the enpkg enstaller, it updated ipython and it looked like everything worked OK.
$ sudo enpkg ipython
prefix: /Library/Frameworks/EPD64.framework/Versions/7.2
No update necessary, 'ipython' is up-to-date.
ipython-1.1.0-6.egg was installed on: Sun Jan 19 23:57:27 2014
$ which ipython
/Library/Frameworks/EPD64.framework/Versions/Current/bin/ipython
$ which python
/Library/Frameworks/EPD64.framework/Versions/Current/bin/python
Any help or suggestions what I can do to get ipython to work again?
Same issue here on my Academic license with Enthought Python Distribution. I followed the steps outlined in answer and can confirm everything is working properly now. There's no mention of this solution on the Enthought Knowledge Base. Thanks!
One addition to the answer: in order to find the directory you need to remove from your system . . .
$ python
import IPython
print IPython
Ok after looking around, I found a problem where someone said another install of ipython might be causing problems. enpkg is trying to install ipython 1.1.0 but I still had 0.13.1 around. So I removed it via:
$ sudo rm -rf /Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/ipython-0.13.1-py2.7.egg
Then it loaded with errors about kernmagic so:
$ sudo enpkg kernmagic
It somehow re-installed ipython 1.0
$ ipython
Python 2.7.2 |EPD 7.3-2 (64-bit)| (default, Sep 7 2011, 16:31:15)
Type "copyright", "credits" or "license" for more information.
IPython 1.0.0 -- An enhanced Interactive Python.
So simply re-trying the enpkg command installs the latest version.
$ sudo enpkg ipython
prefix: /Library/Frameworks/EPD64.framework/Versions/7.2
ipython-1.0.0-2.egg [removing]
12.84 MB [.................................................................]
Jinja2-2.6-2.egg [removing]
1.58 MB [.................................................................]
tornado-2.2-1.egg [removing]
1.42 MB [.................................................................]
tornado-3.1.1-1.egg [installing]
2.16 MB [.................................................................]
Jinja2-2.7.1-1.egg [installing]
1.62 MB [.................................................................]
ipython-1.1.0-6.egg [installing]
12.92 MB [.................................................................]
$ ipython
Python 2.7.2 |EPD 7.3-2 (64-bit)| (default, Sep 7 2011, 16:31:15)
Type "copyright", "credits" or "license" for more information.
IPython 1.1.0 -- An enhanced Interactive Python.
And now it runs without errors. So, hopefully that helps anyone else coming across these kinds of problems.
Related
I recently upgraded to ubuntu 20.04 LTS. As python3.8 was preinstalled, I installed pip using the command sudo apt install python3-pip , and I started installing python3 libraries. All the libraries I install are being installed into ~/.local/lib/Python3.8/site-packages folder. If I remember correctly, these packages should be installed into /usr/local/lib/python3.8/dist-packages.
madhan#madhan:~$ pip3 show tensorflow
Name: tensorflow
Version: 2.2.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages#tensorflow.org
License: Apache 2.0
Location: /home/madhan/.local/lib/python3.8/site-packages
After the packages are installed, I get a warning saying ~/.local/bin is not included in $PATH variable.
Installing collected packages: appdirs, cachelib, pygments, cssselect, lxml, pyquery, howdoi
WARNING: The script pygmentize is installed in '/home/madhan/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script howdoi is installed in '/home/madhan/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed appdirs-1.4.4 cachelib-0.1 cssselect-1.1.0 howdoi-1.2.1 lxml-4.5.1 pygments-2.6.1 pyquery-1.4.1
even if ~/.local/bin is not included in $PATH variable, I am still able to import the packages.
madhan#madhan:~$ python3
Python 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>>
Does anybody know why this is happening? How do I change the default folder to which pip3 packages are installed. Is it okay leave the packages in ~/.local folder or will it be a problem in the future?
I'm using macOS Mojave 10.14.2, and pyenv 1.2.7 .
And these are my configs of pyenv.
python2 seems to work in the terminal.
$ pyenv versions
system
* 2.7.14
3.6.4
$ pyenv global
2.7.14
3.6.4
$ pyenv local
2.7.14
$ python2
Python 2.7.14 (default, Sep 12 2018, 16:35:37)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> (It works!)
But when I use gcloud command, it fails saying it cannot find python2.
$ gcloud config list
pyenv: python2: command not found
The `python2' command exists in these Python versions:
2.7.14
On the other hand, npm command, which requires python2 too, works fine.
It get fixed by pyenv shell command temporarily, but it is valid only until I close the terminal.
(The solution is referred here: https://github.com/pyenv/pyenv/issues/1159)
$ pyenv shell 2.7.14 3.6.4
$ gcloud config list -> Works!
How to fix this problem permanently ?
I was recently encountering this error and found a solution. I am using pyenv with virtual env (pyenv-viritualenv) and I was attempting to run gcloud from inside my python 3 virtual environment.
The issue is that when you run gcloud from a location within the virtualenv, it only knows of the python versions specified in the .python-version file for that directory. You therefore have to specify a python 2 version to run in addition to your python 3 version:
pyenv local <virtualenv name> <python 2 version>
I did this in addition to doing the CLOUDSDK_PYTHON bit mentioned in answers on other related questions:
export CLOUDSDK_PYTHON=$(which python2)
I added this to my .bash_profile
if when you type python on the terminal, it shows different python versions. for example you want to point out to 3.9.0 version. you can type pyenv global 3.9.0
I'm using default version of Python(2.7) on Macbook Pro with High Sierra. I have installed default version of tensorflow, which is 1.9, with this command:
pip -V
>>>pip 18.0 from /usr/local/lib/python2.7/site-packages/pip-18.0-py2.7.egg/pip (python 2.7)
pip install tensorflow
pip list
>>>tensorflow 1.9.0
Then I fire up python:
python
Python 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Then I try to import tensorflow and get this error:
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tensorflow
>>>
I have tried to follow the instructions multiple times with no success. I'd appreciate any help. Thanks.
When you installed tensorflow it might be associated with a different version of python. I suggest you run in virtual environments. Create a virtual environment and activate it. Then once its activated run pip install tensorflow and then try to run your code with your virtual environment still activated.
This link has a much better description of why you need virtual environments and how you install them.
I want to install Pillow and have read in many places this only works if PIL is removed.
Somewhere I have PIL installed but I am unable to find it or remember how it was installed. I'm pretty much a ctrl+c and ctrl+v guy when it comes to installing things through terminal, so I imagine I had some trouble installing it in the first place.
I have tried
pip uninstall PIL
easy_install uninstall PIL
brew uninstall PIL
and run out of ideas. I can't even find any file with name "PIL" with spotlight.
Just want to find a way to get rid of PIL and install Pillow so I can add text to a few hundred images.
Running python 2.7 on El Capitan
To find where PIL is located on your machine, use Python to import it and have it print out its location:
$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
>>> PIL.__file__
On my system, this gives:
'/Library/Python/2.7/site-packages/PIL/__init__.pyc'
From this you can see where your site-packages directory is located. Now exit python, go into /Library/Python/2.7/site-packages/ (your exact path may differ from mine) and delete the folder PIL. That should get rid of it.
cd /Library/Python/2.7/site-packages/
sudo rm -rf PIL
I want to create a virtualenv with python3.4 and pip3 on ubuntu 14.04 but I cannot do it. I've tried in my normal ubuntu14.04LTS machine and in a new one from livecd to check it again from scratch but I cannot make it work. I've tried virtualenv (with and without virtualenvwrapper) and a lot of different commands, tools and scripts I've found around with no luck. Two days lost with this, messing with Python2.7 and specially pip different versions. Let me explain as detailed as possible to help you understand:
As you know, Ubuntu 14.04LTS comes with Python3.4 installed by default and this Python version comes with a tool called py-venv-3.4 so you don't need to use virtual-env and that's the way I'm trying now.
From the clean live-cd I try the following:
sudo apt-get update
sudo pyvenv-3.4 my env
It throws an error:
Error: Command '['/home/ubuntu/Desktop/mi_entorno/bin/python3.4', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
so I have to create it without pip to make it work.
sudo pyvenv-3.4 --clear --without-pip my_env
sudo source my_env/bin/activate
From now on, I'm inside the virtual environment.
At this point I'm good because inside the environment the python command points to the right version (3.4). First common issue solved. But the problem comes with pip. Of course as I checked "without-pip" pip3 doesn't work and I have to install it.
sudo apt-get install python3-pip
sudo pip3 --version
And the fun comes:
pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4)
It's pointing the right version of python, but not the inner one but the outer, for no reason (Outside, pip3 is uninstalled by default!). But just to make sure this is wrong I try to install django in the environment and check it.
sudo pip3 install django
sudo python
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'django'
>>>
Great. Now I go outside the environment back to my "normal" shell:
deactivate
python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 6, 5, 'final', 0)
>>>
And django works as expected cause pip installed it outside the environment. I'm new to Python packaging dependencies and I've lost close to 20 hours with this in my last two days. Does anyone have a simple way to create a single virtual environment on ubuntu14.04 with python3.4 and pip3? I don't think I'm asking for much :(
Any help is a blessing.