I have a numerical simulation program that works fine at the institute I'm in, there I have a Win10 box where I installed Python 3.7.3 64-bit. I am trying to run the same program in my laptop with Manjaro and Python 3.8.1 (It was also 3.7.3 at the time I installed it, but rolling release ¬¬). The problem is that in my laptop I am getting the following error when trying to import pyFFTW
Traceback (most recent call last):
File "/home/User/Documents/Program.py", line 22, in <module>
import pyfftw # Pythonic wrapper for FFTW
File "/usr/lib/python3.8/site-packages/pyfftw/__init__.py", line 43, in <module>
from . import interfaces
File "/usr/lib/python3.8/site-packages/pyfftw/interfaces/__init__.py", line 237, in <module>
from . import scipy_fftpack
File "/usr/lib/python3.8/site-packages/pyfftw/interfaces/scipy_fftpack.py", line 65, in <module>
from scipy.fftpack import (dct, idct, dst, idst, diff, tilbert, itilbert,
ImportError: cannot import name '_fftpack' from 'scipy.fftpack' (/usr/lib/python3.8/site-packages/scipy/fftpack/__init__.py)
Process finished with exit code 1
As far as I can tell the problem is arising from the libraries within the pyFFTW package itself, but I have no idea how to fix it. I tried uninstalling and reinstalling both pyFFTW (1.17.4) and scipy (1.4.1) with little success.
I thought that I could install another version on Python in my Manjaro box and simply "match" all the versions of the packages in the Win box, but I'm looking for a less nuclear solution.
Just for completeness sake, MWE:
$ python
>>> import pyfftw
This is fixed in master. A release should be made shortly. You can either wait for that or pull from github.
Edit: Release made that fixes this on Feb 3 2020.
Related
I am struggling to install and import python libraries into my programs. originally I was using pydev but I kept getting messages like:
Traceback (most recent call last): File "C:\Users\satur\eclipse-workspace\DMD experimental\Main.py", line 11, in <module> from matplotlib import pyplot as plot ModuleNotFoundError: No module named 'matplotlib'
I installed matplotlib using py -m pip install matplotlib which produced a few messages like this.
WARNING: The script f2py.exe is installed in 'C:\Users\satur\AppData\Local\Programs\Python\Python310\Scripts' 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 scripts fonttools.exe, pyftmerge.exe, pyftsubset.exe and ttx.exe are installed in 'C:\Users\satur\AppData \Local\Programs\Python\Python310\Scripts' which is not on PATH.
I was unsure what this meant so I tried running my program again and got the module not found error again.
being unable to resolve the issue I moved over to spyder because it came with many of the libraries I wanted thus avoiding the issue. however, as soon as I tried to import and install libraries not included with spyder I encountered the module not found error and a similar warning about the path. I added the paths mentioned in the warning to the PATH in spyder now when I run my code get this error message:
runfile('C:/Users/satur/.spyder-py3/proper orthogonal decomposition/dynamic mode decomposition experimental driver.py', wdir='C:/Users/satur/.spyder-py3/proper orthogonal decomposition')
Traceback (most recent call last):
File "C:\Users\satur\AppData\Local\Programs\Spyder\pkgs\spyder_kernels\py3compat.py", line 356, in compat_exec
exec(code, globals, locals)
File "c:\users\satur\.spyder-py3\proper orthogonal decomposition\dynamic mode decomposition experimental driver.py", line 13, in <module>
import mat73
File "C:\Users\satur\AppData\Local\Programs\Python\Python310\Lib\site-packages\mat73\__init__.py", line 11, in <module>
import h5py
File "C:\Users\satur\AppData\Local\Programs\Python\Python310\Lib\site-packages\h5py\__init__.py", line 25, in <module>
from . import _errors
ImportError: cannot import name '_errors' from partially initialized module 'h5py' (most likely due to a circular import) (C:\Users\satur\AppData\Local\Programs\Python\Python310\Lib\site-packages\h5py\__init__.py)
I did some looking around and found this
https://github.com/spyder-ide/spyder/wiki/Working-with-packages-and-environments-in-Spyder#installing-packages-into-the-same-environment-as-spyder
I followed what instructions I understood
import sys; sys.executable
Out[50]: 'C:\\Users\\satur\\AppData\\Local\\Programs\\Spyder\\Python\\python.exe'
which is different from what I get when I run it in command prompt or in the pydev terminal both of which give me
C:\Users\satur\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe
when i go to C:\Users\satur\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\ I see: 3 versions of idel, 3 versions of pip, and 6 versions of python.
I am deeply confused. I want to install and import libraries into my python programs. I want to be able to run my programs in either (or for that matter any) ide. I seem to be hitting the very similar issues in both. every tutorial I have found online describes the steps to take to do this but not what they are or why I am doing them none of them seem to work and the more times I try to install things the more confused I get.
could someone please explain: how to install and import libraries into a python program. what python is doing when I install things and try to import them. and why both IDEs have similar but different errors.
I am trying to install py2neo module but ending with below error. Please help me to resolve it.
(base) C:\Users\ADMIN>pip install py2neo Collecting py2neo Using cached https://files.pythonhosted.org/packages/cd/79/a77cc0ad86c021c25dac9f52a0cd33f6832c6af7fa5e58f4438d781ae9c3/py2neo-4.0.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\admin\appdata\local\temp\pip-install-xj8t67\py2neo\setup.py", line 25, in <module>
from py2neo.meta import __author__, __email__, __license__, __package__, __version__
File "py2neo\__init__.py", line 19, in <module>
from py2neo.data import *
File "py2neo\data.py", line 26, in <module>
from py2neo.cypher import LabelSetView, cypher_repr, cypher_str
File "py2neo\cypher\__init__.py", line 36, in <module>
from py2neo.internal.collections import SetView
File "py2neo\internal\collections.py", line 24, in <module>
from py2neo.internal.compat import bytes_types, string_types
File "py2neo\internal\compat.py", line 45, in <module>
DEVNULL = open(devnull, "rw")
ValueError: Invalid mode ('rw')
Command "python setup.py egg_info" failed with error code 1 in c:\users\admin\appdata\local\temp\pip-install-xj8t67\py2neo\
I tried to upgrade setuptools and pip too but didn't able to install py2neo after that also.
My python version is 2.7 and working on win 10 OS.
try this as well :
This is the basic requirements :
Python 2.7 / 3.4 / 3.5 / 3.6 / 3.7
Neo4j 3.2 / 3.3 / 3.4 / 3.5 (the latest point release of each version is recommended)
pip install git+https://github.com/technige/py2neo.git#egg=py2neo
This is a bug in the library. It is illegal to open a file with mode "rw", and they're clearly doing it. You can see the code here. It should almost certainly be using "r+" here.
It's worth noting that this piece of code only runs on old versions of Python, before subprocess.DEVNULL was added in 3.3. While 2.7 is still listed as officially supported, it seems to be in "legacy mode", with a bunch of "compat" code that tries to make 2.7 act like 3.3+, including this line, and some of that compat code is probably not heavily tested.
Also, this piece of code may only be needed on Windows. If so, as the README says:
Note also that Py2neo is developed and tested under Linux using standard CPython distributions. While other operating systems and Python distributions may work, support for these is not available.
So, the fact that their 2.7 compat code is broken on a platform they don't support isn't all that surprising…
What can you do about it?
Try running Python 3.7 or 3.6 instead of 2.7. That will definitely eliminate this problem, and possibly others that you haven't run into yet.
Run a linux VM (/container/user-mode kernel/whatever), and install Python (ideally 3.7) and py2neo under linux. This will definitely eliminate this problem, and possibly others.
Fix the bug yourself and submit a pull request.
File a bug report and wait and see if someone fixes it.
I primarily use python for scientific computing and have become quite accustomed to Spyder. I am working on a mutlimedia project and would like to use the Gstreamer bindings for python. The best way I could find to install Gstreamer on Windows was through PyGi.
Now the problem, import gi works fine in both python and Ipython loaded in a command prompt. However, trying to do the same in Spyder results in:
Traceback (most recent call last):
File "<ipython-input-1-a23efdcdbcd8>", line 1, in <module>
import gi
File "C:\Users\Conner\Anaconda\Lib\site-packages\gi\__init__.py", line 42, in <module>
from . import _gi
ImportError: DLL load failed: The specified module could not be found.
I made sure the interpreter was the same and added C:\Users\Conner\Anaconda\Lib\site-packages to the PYTHONPATH to no avail.
I could develop it outside of Spyder but I am damn stubborn and I don't like when things don't work.
In a round about way, I corrupted my scipy/numpy installation on my IntelX64/Windows 7/Python 2.7 computer. I did this by trying to play around with some neural network libraries (lasagne/theano).
To fix this, I completely removed/reinstalled python 2.7.9. After that, I went to http://www.lfd.uci.edu/~gohlke/pythonlibs/ to download and install numpy and scipy with commands:
pip install C:\Users\me\Documents\numpy-1.9.2+mkl-cp27-none-win_amd64.whl
This went well and succeeded. (I can import numpy from python)
pip install C:\Users\me\Documents\scipy-0.15.1-cp27-none-win_amd64.whl
This appeared to go well too. Except the error occurs in the python console:
>>> from scipy import stats
Gives:
Traceback (most recent call last):
File "<stdin>", line1, in <module>
File "C:\Python27\lib\site-packages\scipy\stats\__init__.py", line 338, in <module>
from .stats import *
File "C:\Python27\lib\site-packages\scipy\stats\stats.py", line 184, in <module>
import scipy.special as special
File "C:\Python27\lib\site-packages\scipy\special\__init__.py", line 586, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.
I read up on the DLLs required and ran the 'dependency walker' (http://www.dependencywalker.com/) on "c:\python27\lib\site-packages\scipy\special_UFUNCS.PYD" and it seems there are a few DLL files not found.
libifcoremd.dll
libiomp5md.dll
libmmd.dll
msvcr90.dll
dcomp.dll
ieshims.dll
and a 6 files that look like 'api-ms-win-....dll'
From my looking around, people have solved this by reinstalling numpy, then scipy. I have tried that and the same thing occurs.
Has anyone else run into this issue and solved it?
I fixed this by a complete removal of everything (python and packages) and then installing everything again.
Just reinstalling the offending packages did not work. Neither did system restore. I will not accept this answer, because removing/installing is a work around to the real problem. I just want to post this to help anyone else in this position.
Simply install 'NumPy-1.9+MKL' from this page, it should work fine.
Acknowledgement: Another post here :)
I am trying to run the following code:
import pymc as pm
alpha = 1.0/count_data.mean() #count_data is the variable that holds txtc
lambda_1 = pm.Exponential("lambda_1", alpha)
lambda_2 = pm.Exponential("lambda_2", alpha)
tau = pm.DiscreteUniform("tau", lower=0, upper=n_count_data)
and keep getting this error:
RuntimeError: module compiled against API version 9 but this version of numpy is 6
Traceback (most recent call last):
File "bayestest.py", line 1, in <module>
import pymc as pm
File "/Library/Python/2.7/site-packages/pymc-2.3-py2.7-macosx-10.8-intel.egg/pymc/__init__.py", line 29, in <module>
from .CommonDeterministics import *
File "/Library/Python/2.7/site-packages/pymc-2.3-py2.7-macosx-10.8- intel.egg/pymc/CommonDeterministics.py", line 21, in <module>
from .utils import safe_len, stukel_logit, stukel_invlogit, logit, invlogit, value, find_element
File "/Library/Python/2.7/site-packages/pymc-2.3-py2.7-macosx-10.8-intel.egg/pymc/utils.py", line 14, in from . import flib
ImportError: numpy.core.multiarray failed to import
Is something wrong with my library installation versions?
If you are on OS X, an easy way to ensure that your Python scientific packages are all compatible is to simply install my Scipy Superpack, or if you don't mind having a second Python installation on your system, to install Anaconda.
I think the OP should accept the answer form Chris Fonnesbeck above.
The PyMC installation was trying to find a numpy installation and came across the version from of numpy that shipped with OS X, thus felt it was too outdated to use. It wasn't because that version of numpy was not good - in fact, it was tested with all other components of the system extensively before distribution, it is just that PyMC requires newer features.
In my personal opinion, the easiest way to go is to install Anaconda, and allow it to register in your system.
EDIT:
Learned the etiquette a bit here, realize I shouldn't add the answer but comment - however, i don't have the privilege yet.