I'm trying to use Theano on ubuntu 14.04, I've followed the guide for an easy install located here http://deeplearning.net/software/theano/install_ubuntu.html#install-ubuntu
Everything says it's installed fine, if I run:
sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libopenblas-dev git
Then I get in return
Reading package lists... Done
Building dependency tree
Reading state information... Done
g++ is already the newest version.
git is already the newest version.
python-dev is already the newest version.
python-nose is already the newest version.
python-numpy is already the newest version.
libopenblas-dev is already the newest version.
python-pip is already the newest version.
python-scipy is already the newest version.
0 to upgrade, 0 to newly install, 0 to remove and 18 not to upgrade.
And when running
sudo pip install Theano
I get
Requirement already satisfied (use --upgrade to upgrade): Theano in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.5.0 in ./.local/lib/python2.7/site-packages (from Theano)
Requirement already satisfied (use --upgrade to upgrade): scipy>=0.7.2 in /usr/lib/python2.7/dist-packages (from Theano)
Cleaning up...
But when I go to run the tests they just don't work.
python -c "import numpy; numpy.test()"
gives me
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/josh/.local/lib/python2.7/site-packages/numpy/__init__.py", line 153, in <module>
from . import add_newdocs
File "/home/josh/.local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/josh/.local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/home/josh/.local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/home/josh/.local/lib/python2.7/site-packages/numpy/core/__init__.py", line 6, in <module>
from . import multiarray
ImportError: /home/josh/.local/lib/python2.7/site-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS4_AsUnicodeEscapeString
and
python -c "import scipy; scipy.test()"
gives me
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named scipy
The last test gives very similar results
josh#josh-GA-78LMT-S2P:~$ python -c "import theano; theano.test()"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named theano
I'm a complete linux newbie so I'm completely baffled by what could be the problem.
If you can, I would simply use a "scientific" Python - either Anaconda (my preference) or Enthought Python. In addition to avoiding systemwide installation of packages, it is easy to install things with pip and numpy and scipy come preinstalled. For updating numpy and scipy you can also use the built-in conda package manager - it does an excellent job of handling the nasty work behind installing a new numpy or scipy.
Related
I have been trying to install tensorflow and I keep getting this error that the module six is not found.
$ python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/name/Library/Python/3.7/lib/python/site-packages/tensorflow/__init__.py", line 38, in <module>
import six as _six
ModuleNotFoundError: No module named 'six'
However when I try to install six, it says Requirement already satisfied.
$ sudo pip3 install six
Password:
WARNING: The directory '/Users/name/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: six in /usr/local/lib/python3.7/site-packages (1.15.0)
What am I doing wrong?
UPDATE/EDIT:
Thank you all for your answers. I ended up using pyenv global 3.7.4 and that fixed all my problems. I'm not really sure why, but I'm sure that I'll understand better as I continue reading about and using Python.
You can try to reinstall the package, that solved a couple of issues in my environment..
pip3 uninstall six
pip3 install six
I installed elastic search curator via the following command.
sudo pip install -U elasticsearch-curator
It all installed OK.
However now when I do the following
curator_cli --version
I get the following dependency warning.
/usr/local/lib/python2.7/dist-packages/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
warnings.warn(warning, RequestsDependencyWarning)
curator_cli, version 5.5.4
How do I either fix the warning or hide it?
So took a couple of things for me to get this working.
First I upgraded cyptography as per Mufeeds suggestion
sudo pip install --upgrade cryptography
This then gave me a new error everytime I did pip <any command>
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip._internal import main
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
Resolved this by resintalling PyOpenSSL
sudo python -m easy_install --upgrade pyOpenSSL
Curator is now working as expected without the warnings
curator_cli --version
> curator_cli, version 5.5.4
This 1st step below will update cryptography, but break pyopenssl.
sudo pip install --upgrade cryptography
We can fix that by removing the pyopennssl library and use pip to reinstall.
sudo rm -rf /usr/lib/python2.7/dist-packages/OpenSSL
sudo rm -rf /usr/lib/python2.7/dist-packages/pyOpenSSL-0.15.1.egg-info
sudo pip install pyopenssl --upgrade
sudo pip install cryptography --upgrade
The last line will produce an error if the open sll library were to still be broken, so this validates all should be well...
My preference is to avoid another package manage like easy install in the mix, so sharing this in case that is anyone else's preference as well.
pip install pyiwn
Requirement already satisfied: pyiwn in ./anaconda/lib/python2.7/site-packages (0.9)
The details of the package are at https://pypi.org/project/pyiwn/ and https://github.com/riteshpanjwani/pyiwn
>>> from pyiwn import pyiwn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/#USER_NAME/anaconda/lib/python2.7/site-packages/pyiwn/pyiwn.py", line 1, in <module>
from pyiwn import utils
ImportError: cannot import name util
can anyone solve this?
We can force a pip re-install, without using the cached version.
pip install --upgrade --force-reinstall pyiwn --no-cache-dir
or for py2.7, pip1.4+ use --no-deps --ignore-installed
Found the problem, the error occurred as the developer didn't mention which python to use. My pip install defaulted to python2. But the pyiwn library only works for python3. That's the reason for utils error.
I'm trying to set up a python 3.6 environment with Django. The installation instructions say I should install mysqlclient to be able to connect to mySQL. I get this:
dennis#django:~$ sudo -H pip3 install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.10.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-4jiw3hvk/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/tmp/pip-build-4jiw3hvk/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-build-4jiw3hvk/mysqlclient/setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-4jiw3hvk/mysqlclient/
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
mySQL is properly installed. What should be in the mysql_config file?
When I try to upgrade pip3 I get this:
dennis#django:~$ sudo -H pip3 install --upgrade pip3
Collecting pip3
Could not find a version that satisfies the requirement pip3 (from versions: )
No matching distribution found for pip3
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
After installing mysqlclient with pip3, I noticed that the module was installed in the python3.5 directory instead of in the python3.6 directory so when I tried to import the MySQLdb module running python3.6, it was not found
dennis#django:~/python_db$ python
Python 3.6.0+ (default, Feb 4 2017, 11:11:46)
[GCC 5.4.1 20161202] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'MySQLdb'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'MySQLdb'
>>>
I then reran using python 3.5 and it was found. How do I install modules using pip3 into the 3.6 directory?
If you're using Mac OS, try this:
brew install mysql
If you're using Ubuntu14/16, try this:
sudo apt install libmysqlclient-dev
and one more:
pip3 can be updated with sudo pip3 install -U pip
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
In my case the issue was solved by doing the following:
sudo aptitude install libmysqlclient-dev
As I was using Python 3.x, the following was also necessary:
sudo aptitude install python3-dev
If you're running MAMP on OSX, do this:
export PATH=$PATH:/Applications/MAMP/Library/bin
In Debian Stretch the required package name seems to have changed to default-libmysqlclient-dev
https://packages.debian.org/stretch/default-libmysqlclient-dev
you can try this to install mysql to a particular python directory, for example w/ python 3.6
sudo python3.6 /usr/bin/pip3 install mysqlclient
Looking over this old question (while looking for something else), I observe that the problem could be that the directory containing mysql_config was not in the current $PATH. Apparently that's what the install script uses to try to find it. It's possible for "mysql to be installed," but not on the $PATH – or for the $PATH to refer to the wrong version.
When I do pip install statsmodels it gives me ImportError: statsmodels requires patsy. http://patsy.readthedocs.org, but then I run pip install patsy and it says its successful, but running pip install statsmodels still gives me same error about requiring patsy.
How can this be?
$ sudo pip install patsy
Requirement already satisfied (use --upgrade to upgrade): patsy in /Library/Python/2.7/site-packages/patsy-0.3.0-py2.7.egg
Requirement already satisfied (use --upgrade to upgrade): numpy in /Library/Python/2.7/site-packages/numpy-1.8.2-py2.7-macosx-10.9-intel.egg (from patsy)
Cleaning up...
$ sudo pip install statsmodels
Downloading/unpacking statsmodels
Downloading statsmodels-0.5.0.tar.gz (5.5MB): 5.5MB downloaded
Running setup.py (path:/private/tmp/pip_build_root/statsmodels/setup.py) egg_info for package statsmodels
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/private/tmp/pip_build_root/statsmodels/setup.py", line 463, in <module>
check_dependency_versions(min_versions)
File "/private/tmp/pip_build_root/statsmodels/setup.py", line 122, in check_dependency_versions
raise ImportError("statsmodels requires patsy. http://patsy.readthedocs.org")
ImportError: statsmodels requires patsy. http://patsy.readthedocs.org
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/private/tmp/pip_build_root/statsmodels/setup.py", line 463, in <module>
check_dependency_versions(min_versions)
File "/private/tmp/pip_build_root/statsmodels/setup.py", line 122, in check_dependency_versions
raise ImportError("statsmodels requires patsy. http://patsy.readthedocs.org")
ImportError: statsmodels requires patsy. http://patsy.readthedocs.org
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /private/tmp/pip_build_root/statsmodels
Storing debug log for failure in /Users/Jacob/Library/Logs/pip.log
What the error message doesn't tell you is that the module six not being there is really the problem.
Found this out by doing import patsy and having it fail and tell me that I needed six. So I did pip install six and now the patsy import worked, as did the pip install statsmodels.
For me:
$python3 -m pip install --upgrade patsy
$python3 -m pip install statsmodels
worked!
For anyone still experiencing issues, I highly recommend this site:
Python libraries. I'm using Python 3, so I,
Downloaded the file named: statsmodels‑0.8.0‑cp35‑cp35m‑win_amd64.whl
Opened windows command prompt
Went to my Downloads directory (cd Downloads)
And then used pip (pip install statsmodels‑0.8.0‑cp35‑cp35m‑win_amd64.whl)
I also had an issue with this in Python 3.4. It worked using the WHL statsmodel file at this link: https://pypi.python.org/pypi/statsmodels#downloads
After the download I installed it using: pip3.4 install my_directory\statsmodels-0.8.0rc1-cp34-none-win_amd64.whl, where my_directory is where I put the WHL file.