I followed a tutorial on C extensions for Python, but when at compilation, I got this error message
>python setup.py build_ext --inplace
Traceback (most recent call last):
File "setup.py", line 2, in <module>
import numpy.distutils.misc_util
ImportError: No module named numpy.distutils.misc_util
I run on Windows10 with VS2008 C++ compiler (as recommanded to compile Python extensions) and Anaconda. When I try to load the module in a python script, I got no error as numpy is well installed.
Related
I just upgraded to pycharm 2022.01 and got an error when debugging a python program using m1 mac:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_cython_wrapper.py", line 8, in <module>
from _pydevd_bundle_ext import pydevd_cython as mod
ModuleNotFoundError: No module named '_pydevd_bundle_ext'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_cython_wrapper.py", line 11, in <module>
from _pydevd_bundle import pydevd_cython as mod
ImportError: cannot import name 'pydevd_cython' from '_pydevd_bundle' (/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 55, in <module>
from _pydevd_bundle.pydevd_trace_dispatch import (
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch.py", line 42, in <module>
from _pydevd_bundle.pydevd_cython_wrapper import trace_dispatch as _trace_dispatch, global_cache_skips, global_cache_frame_skips, fix_top_level_trace_and_get_trace_func
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_cython_wrapper.py", line 35, in <module>
mod = getattr(__import__(check_name), mod_name)
ImportError: dlopen(/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_cython_darwin_310_64.cpython-310-darwin.so, 0x0002): tried: '/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_cython_darwin_310_64.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
Process finished with exit code 1
I installed the right version of pycharm. Couldn't find the right .so version on pypi.
How can I fix this? Is it possible to recompile pydevd for arm64e?
Managed to rebuild pydevd that comes with PyCharm:
Rebuild the binaries
Make sure you have cython installed to update and compile the cython sources:
sudo pip3 install cython
export PYTHONPATH=/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev:$PYTHONPATH
cd /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev
python3.10 build_tools/build.py
After that, debugging in PyCharm worked fine.
Check the binaries
What the rebuild apparently did:
removed all _pydevd_bundle/pydevd_cython_darwin_*.so files
created only _pydevd_bundle/pydevd_cython.cpython-310-darwin.so
Use the file command to confirm the binary has the architecture required for new M1 (Apple Silicon) chips:
file _pydevd_bundle/pydevd_cython.cpython-310-darwin.so`
It should output required architecture for M1 like arm64 below:
_pydevd_bundle/pydevd_cython.cpython-310-darwin.so: Mach-O 64-bit bundle arm64
As a quickfix, you can simply disable cython debugging. This will still enable you to run a debugging session, albeit with less features.
Add this to the environment variables of your run configuration in PyCharm:
PYDEVD_USE_CYTHON=NO
I get this error when I try to import pandas after installing it using pip install and I'm using IntelliJ
C:\Users\Start\venv\Pyhon3.7\Scripts\python.exe D:/PYTHON/HelloWorld/HelloWorld.py
Traceback (most recent call last):
File "C:\Users\Start\venv\Pyhon3.7\lib\site-packages\pandas\__init__.py", line 30, in <module>
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
File "pandas\_libs\hashtable.pyx", line 1, in init pandas._libs.hashtable
ImportError: DLL load failed: %1 is not a valid Win32 application.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/PYTHON/HelloWorld/HelloWorld.py", line 25, in <module>
import pandas as pd
File "C:\Users\Start\venv\Pyhon3.7\lib\site-packages\pandas\__init__.py", line 38, in <module>
"the C extensions first.".format(module)
ImportError: C extension: DLL load failed: %1 is not a valid Win32 application. not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
If you are using Pycharm
Go to settings.
Go to Project: (Project-name)
Go to Project Interpreter and all the modules you have downloaded. Maybe pandas was not installed correctly
Please check if the python version you are using is also 64 bit. If not then that could be the issue. You would be using a 32 bit python version and would have installed a 64 bit binaries for the pandas library.
You can also go to Unofficial Windows Binaries for Python Extension Packages to find any python libs.
I'm unable to import any external packages currently installed on any of my conda enviroments on either VS code or the command line.
For example after running the below command for my scripts env:
C:\Users\UserName>C:\\Users\\UserName\\AppData\\Local\\Continuum\\miniconda3\\envs\\scripts\\python.exe -c "import pandas"
The below traceback message is displayed:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\UserName\AppData\Local\Continuum\miniconda3\envs\scripts\lib\site-packages\pandas\__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy: DLL load failed: The specified module could not be found.
I can run the same command in the Anaconda Prompt terminal (or import pandas on a Jupyter Notebook) and no Traceback is displayed. Thank you in advance.
Note:: I've used this page as reference
I want to use pyfftw module and I install it using sudo apt-get install python-fftw. The FFTW module is already installed. However, when I try to import pyfftw this error happens:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pyfftw/__init__.py", line 16, in <module>
from .pyfftw import (
ImportError: /usr/lib/python2.7/dist-packages/pyfftw/pyfftw.arm-linux-gnueabihf.so: undefined symbol: fftwl_plan_with_nthreads
Anyone knows how to troubleshoot this? For additional information, my system architecture is armv7l (I am running the program in odroid), my OS is Ubuntu and I use python 2.7.12.
Thank you.
I installed anaconda with python 2.7 recently and I'm trying to run a script which uses pandas, but it doesn't work. I looked around and I haven't managed to find a solution yet. I'm running windows 10. Any help on this would be greatly appreciated!
$ python bitstamp.py
Traceback (most recent call last):
File "bitstamp.py", line 22, in <module>
import integrate_function
File "C:\Users\Jinzo\Desktop\zeta_v05\integrate_function.py", line 22, in <module>
import pandas as pd
File "C:\Python27\lib\site-packages\pandas\__init__.py", line 35, in <module>
"the C extensions first.".format(module))
ImportError: C extension: DLL load failed: %1 is not a valid Win32 application. not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
Edit: I don't know what setup.py it refers to in the error message. Running this just gives
python setup.py build_ext --inplace --force
C:\Python27\python.exe: can't open file 'setup.py': [Errno 2] No such file or directory