Today I upgraded to Xubuntu 13.04 which comes with Python 3.3. Before that, I was working with Pyton 3.2, which was working perfectly fine.
When running my script under Python 3.3, I get an
ImportError: No module named 'pylab'
in import pylab.
Running in Python 3.2, which I reinstalled, throws
ImportError: cannot import name multiarray
in import numpy.
Scipy, numpy and matplotlib are, recording to apt, on the newest version.
I don't have much knowledge about this stuff. Do you have any recommendations on how to get my script to work again, preferably on Python 3.2?
Thanks in advance,
Katrin
Edit:
We solved the problem: Apparently, there where a lot of fragments / pieces of the packages in different paths, as I installed from apt, pip as well as manually. After deleting all packages and installing them only via pip, everything works fine. Thank you very much for the help!
I suspect you need to install python3-matplotlib, python3-numpy, etc. python-matlab is the python2 version.
You need to install all python libraries you installed for Python 3.2 also for 3.3.
Related
I have multiple python interperters in my computer 3.7 and 3.8. When I debug using with python 3.8 I do not face any issues using VSCode. My VScode python debugger fails when trying to debug with python 3.7. How do I install ctypes for python 3.7?
File "/home/kumar/.vscode/extensions/ms-python.python-2021.5.842923320/pythonFiles/lib/python/debugpy/launcher/../../debugpy/launcher/debuggee.py", line 8, in <module>
import ctypes
File "/usr/local/lib/python3.7/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
Try pip uninstall ctypes, and then uninstall and reinstall ur python 3.7 and then try again pip install ctypes and then import ctypes in python interpreter.
ctypes is a built in library (I think from python2.5)
This means you dont need to install it, it is coming built in when you install python.
As far as using the correct version, see the pyenv module - it will make sure you are running the correct python version, and IMO makes life much easier
Have you checked which pip you are using? Make sure you have taken the right pip to install the package in the right place.
You can take pip --version command to check which pip you are using.
i installed python3.7 on ubuntu using ppa:deadsnakes/ppa repository.
When I try to run
import cmath
in python shell it fails with message:
ModuleNotFoundError: No module named 'cmath'
I didn't find any info about depracation of this library or anything in python3.7 changelog. It works fine in pythons 3.5 and 2.7. I tried installing it on different ubuntu virtual machines and computers and I always get the same result.
Do I need to install some specific library or something (which I doubt because the module is listed in standard library https://docs.python.org/3/library/index.html) or is problem elsewhere?
This was a bug in the deadsnakes backport of python3.7 specifically for xenial.
During the 3.7 beta period (when the package was imported). The cpython build system used PY_CORE_CFLAGS as a make variable. It was later changed to PY_STDMODULE_CFLAGS. debian ships a patch with their package that adjusts a generated makefile line using a sed expression for that specific variable. Since this was missing it caused the cmath module to build incorrectly.
This has been fixed in this commit
This fix is available in 3.7.0-1+xenial2 (debian version)
I installed python3.7 by downloading and installing it using make and cmath started working. It looks like ppa:deadsnakes/ppa repository had missing cmath module.
I trying to run a program in python 2.7 that uses numpy but it gives me the error ImportError: No module named numpy. I am using Windows 10. I tried running pip install numpy and it says it was installed but I still can't run the program.
I think Pip installed your package for Python3.
That's why your python can't find Numpy
If you want to use NumPy for Python2 you must install directly 1.13.3 cp27 version, or you must install Python3.
You can check NumPy and Python versions here.
https://pypi.python.org/pypi/numpy
My personal advice is to use Python3. It's not a good time to use Python2 I think.
You can check some resources
https://wiki.python.org/moin/Python2orPython3
http://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html
https://www.activestate.com/blog/2017/01/python-3-vs-python-2-its-different-time
I've just installed Python 3.5 to experience its functionality. The problem is that all the modules I use in my daily programming have been installed and run very well on it except Matplotlib. I installed it via pip and never faced any errors while installing, but when I wanted to import it, the error saying, DLL load failed: The specified module could not be found. popped up.
What's the matter with Python 3.5, or Matplotlib?
Uninstall the module using pip uninstall matplotlib then install it again using http://matplotlib.org/downloads.html
Obtain the .exe file that best fits your machine, in my case it would be matplotlib-1.4.3.win-amd64-py3.4.exe. This will be a more complete version of matplotlib for windows rather than using pip.
I would also consider rolling back to Python 3.4 unless you absolutely need 3.5. There shouldn't be a compatibility issue between 3.4 and 3.5 for Python, but as far as matplotlib it's been tested with 3.4, but if you run through problems on 3.5 I would roll back.
If you have Python 3.5 you should install MS's Redistributable DLLs to make matplotlib working on Windows... In my case, no need to reinstall matplotlib even...
Try this example without. If error appears install that and try with it (you must log in MS site and download version for arch you using - i tested x86 only, Windows 7, Python 3.5).
That case is included in matplotlib install documentation!
Remember, you should always read documentation before you ask!
My system: Mac OS X 10.6.8, gcc 4.2, python 2.7, xcode 3.2.3
I use python 2.7 and I got error when tried to do: import objc, it returns: ImportError: No module named objc.
It looks like the objc module is not there. But actually I have the objc module installed already. Snow Leopard has got pyobjc preinstalled and I have also checked this using python2.6 (I have python 2.7 and 2.6 in my Mac). So if I invoke import objc using python2.6, I got no error which means objc exists and I can use that module without problems ... but if I import using python 2.7, I will got the ImportError: No module named objc error.
Does anyone have any solution? FYI, the python2.6 is coming preinstalled with OS X while 2.7 is manually installed. I've been using the 2.7 for couple of months without problems.
Python C extension modules like objc cannot be re-used between python versions. You'll have to install the objc module for 2.7 separately.
Generally, different python installations (such as 2.6 or 2.7, or 3.2) use separate module import locations, and you normally install extensions per python setup.
In general, packages installed with one python installation are not available to other python installations. You can make them available by messing with sys.path (or by setting PYTHONPATH in your environment) and installing your modules to a common place, however, as pointed out by #MartijnPieters, if it is a C extension, you'll need to re-build the module for python 2.7 (and then you can't put it in a common place). Usually, this is as easy as:
<sudo> python2.6 setup.py install #install for python 2.6
<sudo> python2.7 setup.py install #install for python 2.7
since the command python is generally just a (soft) link to your preferred python installation.
sudo may or may not be necessary depending on where your python implementations live on your path.
This works for pure python modules too by the way. Since the source code generally doesn't take up too much space, this may be a good way to install all your modules if you'll be switching back and forth between python 2.6 and python 2.7.
The same thing goes if you're using easy_install to install your packages:
easy_install-2.6 somepackage
easy_install-2.7 somepackage