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.
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?
Pyspark is installed in my Mac. This error I am getting while I try to run Pyspark from the command line.
I am installing Pyspark using homebrew and following instructions in this blog(https://medium.com/#roshinijohri/spark-with-jupyter-notebook-on-macos-2-0-0-and-higher-c61b971b5007).
When I start running Pyspark in the shell I am getting the following error.
Python 3.7.1 (default, Dec 14 2018, 13:28:58)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
Intel MKL FATAL ERROR: Cannot load libmkl_core.dylib.
MKL is Intel's "Math Kernel Library", and it basically handles calculations.
The new version of Numpy uses MKL by default, and that is likely why this error is showing up.
Try to update numpy,
conda update numpy
or disable MKL by
conda install nomkl
Hope that helped!
Reference:
https://github.com/BVLC/caffe/issues/3884
First of all, I tried all the solutions above and neither of them solved this issue for me. For the folks that have a similar situation to me, I'm writing the solution that solved this bug below.
In my case, I have an anaconda virtual environment and doing all of the stuff in there.
Instead of removing mkl, or installing nomkl and etc. I installed it again by using the command:
conda install -c anaconda mkl
This solved the issue for me which I'm trying to solve for a day. I hope it also would be useful for you folks too.
Update your mkl package. That should fix this.
i am struggling to get pycups to work in a conda environment.
I get Symbol not found: _libiconv.
I'm running on macOS Mojave.
I assume it is a path problem because on the same machine it works fine installed in an environment created using python3: python3 -m venv myenv
but with conda, no such luck:
conda create myenv python=3.7
conda activate myenv
pip install pycups
python
Python 3.7.3 (default, Mar 27 2019, 16:54:48)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cups
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/anaconda3/envs/myenv/lib/python3.7/site-packages/cups.cpython-37m-darwin.so, 2): Symbol not found: _libiconv
Referenced from: /anaconda3/envs/myenv/lib/python3.7/site-packages/cups.cpython-37m-darwin.so
Expected in: /usr/lib/libiconv.2.dylib
in /anaconda3/envs/myenv/lib/python3.7/site-packages/cups.cpython-37m-darwin.so
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.
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.