Using the following code
import numpy as np
from scipy.signal import fftconvolve
import matplotlib.pyplot as plt
gives the following stack trace
Traceback (most recent call last):
File "/Users/Erik/Documents/workspace-
python/src/pywavelets/Problem1/Problem1.py", line 8, in <module>
from scipy.signal import fftconvolve
File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/signal/__init__.py", line 311, in <module>
from . import sigtools, windows
File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/signal/windows/__init__.py", line 40, in <module>
from .windows import *
File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/signal/windows/windows.py", line 9, in <module>
from scipy import fftpack, linalg, special
File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/fftpack/__init__.py", line 99, in <module>
from .basic import *
File "/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/fftpack/basic.py", line 12, in <module>
from . import _fftpack
ImportError:
dlopen(/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/fftpack/_fftpack.cpython-36m-darwin.so, 2): Symbol not
found: _main
Referenced from:
/Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/fftpack/_fftpack.cpython-36m-darwin.so
Expected in: flat namespace
in /Users/Erik/anaconda3/envs/tensorflow/lib/python3.6/site-
packages/scipy/fftpack/_fftpack.cpython-36m-darwin.so
I've tried reinstalling numpy and scipy using pip, but didn't do anything.
Perhaps I need to specify some library in PYTHONPATH? I've read elsewhere that PyDev should automatically detect necessary imports, and numpy and tensorflow seem to work fine without any outside directories specified.
I do know that the error is specific to PyDev, since the code executes fine in the console.
Can anyone help me pinpoint the problem? Thank you!
If it works in the console an not in PyDev, please check if your environment variables are the same in both cases.
i.e.:
for key, val in sorted(os.environ.items()):
print('%s=%s' % (key, val))
Run both and save the output in different files and then compare to see what's different. The most likely culprits are LD_LIBRARY_PATH, PATH and PYTHONPATH...
One thing to check is running Eclipse from the same console where you got things running (as it should inherit those variables).
Related
I'm new to conda, but I'm sure I have pandas installed in the base environment. I also have selected it as the python interpreter in VSCode. However, when I try to import pandas it throws the following error:
Traceback (most recent call last):
File "/Users/raimundbuehler/Documents/UNIDOCS/Python:Psychopy:RALT/Rando/Randomization.py", line 2, in <module>
import pandas as pd
File "/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/__init__.py", line 22, in <module>
from pandas.compat import is_numpy_dev as _is_numpy_dev
File "/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/compat/__init__.py", line 15, in <module>
from pandas.compat.numpy import (
File "/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/compat/numpy/__init__.py", line 4, in <module>
from pandas.util.version import Version
File "/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/util/__init__.py", line 1, in <module>
from pandas.util._decorators import ( # noqa:F401
File "/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/util/_decorators.py", line 14, in <module>
from pandas._libs.properties import cache_readonly # noqa:F401
File "/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/_libs/__init__.py", line 13, in <module>
from pandas._libs.interval import Interval
ImportError: dlopen(/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/_libs/interval.cpython-39-darwin.so, 0x0002): rebase opcodes terminated early at offset 1 of 1800
I'm assuming numpy to be the problem, but updating both numpy and pandas didn't solve it. It may also be because I have Pycharm and pip installed, so it may be messy regarding multiple installations of python and packages... in fact in Pycharm, I can import pandas (using a different interpreter). Any help how to find out if this is indeed the case and how to solve it would be greatly appreciated!
I refer to this issue.
I think the feasible way may still be to unload and reinstall.
I just installed python xy 2.7.9 on Windows 7. I went to run some previously written code in Spyder which calls:
from scipy.sparse import linalg as sla
However, I get the following error:
File "C:\Python27\lib\site-packages\scipy\sparse\linalg\__init__.py", line 113, in <module>
from .matfuncs import *
File "C:\Python27\lib\site-packages\scipy\sparse\linalg\matfuncs.py", line 20, in <module>
import scipy.misc
File "C:\Python27\lib\site-packages\scipy\misc\__init__.py", line 44, in <module>
from . import doccer
ImportError: cannot import name doccer
Does anyone know how to fix this? I find this weird because it worked with my previous copy of Python (which I uninstalled before installing the new version).
Thanks!
What worked for me is moving doccer.py from "misc" folder to "_lib" folder (which are in path /usr/lib/python3/dist-packages/scipy/ for me).
I found this in a release note of scipy : https://github.com/scipy/scipy/pull/9652
I'm trying to run a naive bayes script that needs NumPy, SciPy and Pandas to run. To avoid the confusion with the multiple copies of python on Macs 10.7 --and because I couldn't figure out how to, really - I made a virtualenv and installed NumPy and SciPy there, checking that after running
$ python
>>> import numpy
>>> import scipy
everything works. Now, I'm in my file's directory, and running python nb_predict.py gives me a bunch of errors.
Originally, the path to my python compiler at the top of my file was
#!/usr/local/bin/python
but since I didn't know if it had changed after installing everything in the virtual env, I've tried it with:
#!/Users/myusername/.virtualenvs/scipy/bin/python
and it still doesn't work. I've made the script executable, also.
Please, any help would be greatly appreciated!
This is what I get as the error:
Traceback (most recent call last):
File "nb_predict.py", line 3, in <module>
from sklearn.naive_bayes import MultinomialNB
File "/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scikit_learn-0.15_git-py2.7-macosx-10.9-intel.egg/sklearn/naive_bayes.py", line 25, in <module>
from .preprocessing import binarize
File "/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scikit_learn-0.15_git-py2.7-macosx-10.9-intel.egg/sklearn/preprocessing/__init__.py", line 22, in <module>
from .imputation import Imputer
File "/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scikit_learn-0.15_git-py2.7-macosx-10.9-intel.egg/sklearn/preprocessing/imputation.py", line 10, in <module>
from scipy import stats
File "/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scipy-0.14.0.dev_572aaf0-py2.7-macosx-10.9-intel.egg/scipy/stats/__init__.py", line 332, in <module> from .stats import *
File "/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scipy-0.14.0.dev_572aaf0-py2.7-macosx-10.9-intel.egg/scipy/stats/stats.py", line 181, in <module>
import scipy.special as special
File "/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scipy-0.14.0.dev_572aaf0-py2.7-macosx-10.9-intel.egg/scipy/special/__init__.py", line 532, in <module>
from ._ufuncs import *
ImportError: dlopen(/Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scipy-0.14.0.dev_572aaf0-py2.7-macosx-10.9-intel.egg/scipy/special/_ufuncs.so, 2): Symbol not found: ___sincos_stret
Referenced from: /Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scipy-0.14.0.dev_572aaf0-py2.7-macosx-10.9-intel.egg/scipy/special/_ufuncs.so
Expected in: /usr/lib/libSystem.B.dylib
in /Users/myusername/.virtualenvs/scipy/lib/python2.7/site-packages/scipy-0.14.0.dev_572aaf0-py2.7-macosx-10.9-intel.egg/scipy/special/_ufuncs.so
This question already has an answer here:
matplotlib not working anymore due to interactive issue
(1 answer)
Closed 9 years ago.
Disclaimer: I'm new to python and first post, so I apologize if this isn't formatted correctly or somewhere on the site. I haven't found anything thus far though.
I'm using Python 2.7 (32 bit) on Win7 (64 bit) and trying to use matplotlib to generate simple plots. I have numpy, scipy, and installed matplotlib. matplotlib is installed as 32bit.
I have a script ('different.py') that has only one line:
import matplotlib.pyplot as plt
running this script in the command prompt returns the following error:
C:\Users\Robert\Desktop>python different.py
Traceback (most recent call last):
File "different.py", line 1, in <module>
import matplotlib as plt
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 165, in <module>
from matplotlib.rcsetup import (defaultParams,
File "C:\Python27\lib\site-packages\matplotlib\rcsetup.py", line 20, in <module>
from matplotlib.colors import is_color_like
File "C:\Python27\lib\site-packages\matplotlib\colors.py", line 54, in <module>
import matplotlib.cbook as cbook
File "C:\Python27\lib\site-packages\matplotlib\cbook.py", line 34, in <module>
import new
File "C:\Users\Robert\Desktop\new.py", line 1, in <module>
import matplotlib.pyplot
File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 23, in <module>
from matplotlib import _pylab_helpers, interactive
ImportError: cannot import name interactive
However, when i open the python (command line) program, and enter
import matplotlib.pyplot as plt
plt
it runs and returns
< module 'matplotlib.pyplot' from 'C:\Python27\lib\sitepackages\matplotlib\pyplot.pyc'>
so as far as I can tell it imports the library from the shell, but it's having an issue in the command prompt, and I have no idea why. The only post I've seen related said it was having trouble importing the name interactive because the user had titled their script as "new". I had that originally, but saved the script as 'different.py' thinking it would fix the issue, which it didn't.
Any idea as to why the ImportError is occuring in the command prompt but not the shell?
You still have a file called new.py on your desktop. Somewhere along in the chain of import statements, there is an "import new", which finds your new.py, and everything goes wrong:
File "C:\Python27\lib\site-packages\matplotlib\cbook.py", line 34, in <module>
import new
File "C:\Users\Robert\Desktop\new.py", line 1, in <module>
import matplotlib.pyplot
Remove or rename your new.py as well as any corresponding new.pyc that may have been created, and try again, or try again from a different working directory.
I am currently using Python 2.7 and Numpy 1.6.2. I want to use the numpy.polyfit() function with the weights parameter. However, it seems that the weights parameter is not available in numpy 1.6.2. The Sourceforge download link shows 1.6.2 as being the latest version. I have found the updated polynomial.py file which includes the weights parameter for the polyfit() function. I simply replaced my current polynomial.py with the updated one on the website. However, when I try to run my Python program, I get the error:
Traceback (most recent call last):
File "C:\Python27\first.py", line 13, in <module>
import matplotlib
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 133, in <module>
from matplotlib.rcsetup import (defaultParams,
File "C:\Python27\lib\site-packages\matplotlib\rcsetup.py", line 19, in <module>
from matplotlib.colors import is_color_like
File "C:\Python27\lib\site-packages\matplotlib\colors.py", line 52, in <module>
import numpy as np
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 153, in <module>
import polynomial
File "C:\Python27\lib\site-packages\numpy\polynomial\__init__.py", line 18, in <module>
from polynomial import Polynomial
ImportError: cannot import name Polynomial
first.py is simply the file with all my code I'm trying to run
What am I doing wrong? Is there another way to simply get the newest version of Numpy (1.7?) ?
Thank you for your help!
There are two files called polynomial.py in NumPy; lib/polynomial.py and polynomial/polynomial.py. You've replaced the wrong one.
I'm not aware of any development builds of 1.7.x for Windows; if you're comfortable with building packages yourself then you can download the source using git and build it per instructions from https://github.com/numpy/numpy/blob/master/doc/HOWTO_RELEASE.rst.txt and linked resources.