I installed anaconda, but I'm also using pip:
$ conda list scipy
# packages in environment at /Users/bjelline/anaconda:
#
scipy 0.14.0 np19py27_0
$ conda list pybrain
# packages in environment at /Users/bjelline/anaconda:
#
pybrain 0.3 <pip>
These two are supposed to work together, aren't they?
when I do
/Users/bjelline/anaconda/bin/python -c "import pybrain"
I get an error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/bjelline/anaconda/lib/python2.7/site-packages/pybrain/__init__.py", line 1, in <module>
from structure.__init__ import *
File "/Users/bjelline/anaconda/lib/python2.7/site-packages/pybrain/structure/__init__.py", line 1, in <module>
from connections.__init__ import *
File "/Users/bjelline/anaconda/lib/python2.7/site-packages/pybrain/structure/connections/__init__.py", line 1, in <module>
from full import FullConnection
File "/Users/bjelline/anaconda/lib/python2.7/site-packages/pybrain/structure/connections/full.py", line 3, in <module>
from scipy import reshape, dot, outer
ImportError: cannot import name reshape
any thoughts what the problem might be?
the problem wasn't anaconda, or python, or pip. The problem were files called
pybrain.py
and
scipy.py
in the current directory. the current directory is first in sys.path, so these files got loaded instead of the real libraries.
Note to self: never reuse a packages name as your own filename!
Try conda install -f scipy. This will force reinstall scipy.
Related
I have installed jax and jaxlib using pip according to https://github.com/google/jax#installation:
Successfully installed jax-0.1.68 jaxlib-0.1.67+cuda11
But after i ran my project, it showed Importerror:
Traceback (most recent call last):
File "...", line 1, in <module>
from jax import jit, jacfwd, jacrev, hessian, lax
File "...", line 16, in <module>
from .api import (
File "...", line 38, in <module>
from . import core
File "...", line 30, in <module>
from . import dtypes
File "...", line 31, in <module>
from .lib import xla_client
File "...", line 51, in <module>
from jaxlib import pytree
ImportError: cannot import name 'pytree' from 'jaxlib' (/home/control/.local/lib/python3.7/site-packages/jaxlib/__init__.py)
Could this problem comes from uncompatible jax/jaxlib version for running the project?
If not, how to deal with it?
It appears that you are importing a much older jax version than you report in the question; jax.lib has not attempted to import pytree from jaxlib since version 0.2.8.
This probably indicates that you are running pip install in a different environment than the one you're using to execute code.
Assuming you are working at the command prompt, try this instead:
$ python -m pip install jax jaxlib
$ python -c "import jax; print(jax.__version__)"
(where you can replace python in both lines with whatever python executable you are using)
If you're working in Jupyter with different kernels, this answer might help you understand how to proceed: Running Jupyter with multiple Python and IPython paths
I'm trying to upgrade some packages and to consolidate my requirements.txt for an existing python program in order to move it to a docker container.
This container will be based on the tensorflow docker container, this dictates some package versions I have to use. We work under windows and we want to be able to run the program locally on our machines (at least for some time). So I need to find a configuration that works in docker and on Windows 10.
Tensorflow 2.4.1 needs numpy~=1.19.2. When using numpy 1.20, pip complains that numpy 1.20 is an incompatible version.
But when using numpy~=1.19.2 I get the following error when importing cvxpy. pip installs all packages just fine:
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
Traceback (most recent call last):
File "test.py", line 1, in <module>
import cvxpy
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\__init__.py", line 18, in <module>
from cvxpy.atoms import *
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\atoms\__init__.py", line 20, in <module>
from cvxpy.atoms.geo_mean import geo_mean
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\atoms\geo_mean.py", line 20, in <module>
from cvxpy.utilities.power_tools import (fracify, decompose, approx_error, lower_bound,
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\utilities\power_tools.py", line 18, in <module>
from cvxpy.atoms.affine.reshape import reshape
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\atoms\affine\reshape.py", line 18, in <module>
from cvxpy.atoms.affine.hstack import hstack
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\atoms\affine\hstack.py", line 18, in <module>
from cvxpy.atoms.affine.affine_atom import AffAtom
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\atoms\affine\affine_atom.py", line 22, in <module>
from cvxpy.cvxcore.python import canonInterface
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\cvxcore\python\__init__.py", line 3, in <module>
import _cvxcore
ImportError: numpy.core.multiarray failed to import
Steps to reproduce:
1.)
Create a new Python 3.8 venv under Windows 10 and activate it
2.) Install the following requirements.txt via pip install -r requirements.txt:
cvxpy
numpy~=1.19.2 # tensorflow 2.4.1 requires this version
3.) Execute the following test.py via python test.py
import cvxpy
if __name__ == '__main__':
pass
The same thing happens if I want to use tensorflow 2.3. In this case numpy~=1.18 is needed, the error is exactly the same.
Searching for the error finds very few hits which sadly did not help me.
What can I do to solve this?
I'm learning python and I'm using OS X. I've installed anaconda 3 and set up env called testenv with python 3.5. Then I activated recently created env and installed several packages such as numpy, pandas and opencv3. Nevertheless, when I run python shell and type "import numpy" I get the following errors:
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): Symbol not found: _PyBuffer_Type
Referenced from: /usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so
Expected in: flat namespace
in /usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so
The same happens with other packages.
File "/usr/local/lib/python2.7/site-packages/numpy/init.py", line
180, in
Python is picking up the packages from the system's Python packages and not from the packages installed in your virtualenv i.e. testenv.
Be sure that you have activated the virtualenv with something like:
source testenv/bin/activate
and then try running Python.
And you said you set it up with Python 3.5 but it's picking path with python2.7.
Let me know if that solves your problem.
I solved this problem by simply writing this command:
sudo python3 -m pip install --upgrade numpy
Another possible method to fix it is to eliminate /usr/local/lib/python2.7 in PYTHONPATH
On a Mac.... this is how to do this safely
brew install python3
Lets now add a virtual env called pe35
python3 -m venv ~/pe35
Now lets use the virtualenv
source ~/pe35/bin/activate
If you want a symbol - place this in you .bash_profile
alias pe35='source ~/pe35/bin/activate'
Now to install numpy in your virtualenv
pip install numpy
I have been trying to install and use scikit-learn and nltk. However, I get the following error while importing anything:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/sklearn/init.py", line 57, in
from .base import clone
File "/usr/local/lib/python2.7/site-packages/sklearn/base.py", line 11, in
from .utils.fixes import signature
File "/usr/local/lib/python2.7/site-packages/sklearn/utils/init.py", line 10, in
from .murmurhash import murmurhash3_32
File "numpy.pxd", line 155, in init sklearn.utils.murmurhash (sklearn/utils/murmurhash.c:5029)
ValueError: numpy.dtype has the wrong size, try recompiling
I did a pip uninstall numpy followed by a pip install numpy and also a pip uninstall scikit-learn and again reinstalled it. But the error persists.
I met the same problem today. Now I have solved it.
Because I have installed numPy manually, and I use the command "pip" to install the else package.
Solve way:
find the old version of numPy.
You can import numPy and print the path of it.
delete the folder.
use pip to install again.
I am on OS X 10.11.2, Anaconda Python 2.7.10.
I was installing some dependencies, and suddenly, my conda command started not working at all. Many people suggest conda install python=2.7.10 but when I try that (or any command, even just conda) I get:
Traceback (most recent call last): File
"/Users/Can/anaconda/bin/conda", line 5, in
sys.exit(main()) File "/Users/Can/anaconda/lib/python2.7/site-packages/conda/cli/main.py",
line 106, in main
from conda.cli import conda_argparse File "/Users/Can/anaconda/lib/python2.7/site-packages/conda/cli/conda_argparse.py",
line 16, in
from conda.cli.find_commands import find_commands, find_executable File
"/Users/Can/anaconda/lib/python2.7/site-packages/conda/cli/find_commands.py",
line 9, in
from conda.utils import memoized File "/Users/Can/anaconda/lib/python2.7/site-packages/conda/utils.py", line
10, in
import tempfile File "/Users/Can/anaconda/lib/python2.7/tempfile.py", line 32, in
import io as _io File "/Users/Can/anaconda/lib/python2.7/io.py", line 51, in
import _io ImportError: dlopen(/Users/Can/anaconda/lib/python2.7/lib-dynload/_io.so, 2):
Symbol not found: __PyCodecInfo_GetIncrementalDecoder Referenced
from: /Users/Can/anaconda/lib/python2.7/lib-dynload/_io.so Expected
in: dynamic lookup
How can I repair conda, without using conda itself (as I can't)?
UPDATE: I've completely uninstalled and reinstalled Anaconda. It still gives the same error. I've tried pip and it also fails with the same error. I verify it's Anaconda's pip as which pip returns /Users/Can/anaconda2/bin/pip. Why is Anaconda broken?
I had the same issue, it is successfully fixed by just replacing the _io.so file.
sudo find / -name _io.so
copy the path of the _io.so file which DOES NOT belong to python-2.7.11. For example, copy the path of _io.so which is under python-2.7.5:
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Replace the '/Users/Can/anaconda/lib/python2.7/lib-dynload/_io.so' file with the _io.so that you just found.
cp /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so /Users/Can/anaconda/lib/python2.7/lib-dynload/
Then it will work.