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.
Related
Probably stupidly I tried to install the latest version of Python, in this case using the download from python site, but after doing that I was then getting python still running on the previous version python-3.6. I'm on OSX and was using sublime.
So I have been trying to work out how to update it to use the newest version. I've followed; https://opensource.com/article/19/5/python-3-default-mac.
All of the responses to queries now point to the python-3.9.5 version. So that's great and my runtime is using that. However after installing the requests using pip install I get the following error when running.
import requests
ModuleNotFoundError: No module named 'requests'''
[path: /Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
I stumbled upon Modules are installed using pip on OSX but not found when importing which I have been trying to work through.
I have been able to run the import command successfully in terminal, however it's intermittent as I've tried again and it's broken, so I'm lost. I'm running it something trying to run the python3.6 version, which after updating I followed these instructions to remove when I have uninstalled that from my mac https://www.macupdate.com/app/mac/5880/python/uninstall.
If there is any ideas, would love some help, mainly to try and tell me what that error message is telling me.
In particular, what does this mean?
[path: /Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.6/
I should clarify too; when I run 'pip list'
I see
requests 2.25.1
Assuming that you are not installing requests package properly, and assuming your python executable is named python:
python -m pip install requests
If however, your python executable is named something else instead, e.g. python3, replace python with that name:
python3 -m pip install requests
I am trying to follow a tutorial book called "Data visualization with Python and Javascript" and am running into many issues importing modules used in the book. I have made sure to do "pip install" on as many of the packages used as possible, and have successfully done it for packages such as SQLAlchemy and matplotlib.
However, when I import modules from SQLAlchemy and even dateutil that are used in the tutorial, I receive an import error, "ImportError: No module named {module}"
On the following lines of code:
from dateutil import parser
from SQLAlchemy import create_engine
This has occurred often enough with different modules that I am beginning to get concerned I can no longer actually follow the tutorial. I had to skip a whole section of how to use SQLAlchemy.
Furthermore, SQLAlchemy is properly installed:
Requirement already up-to-date: sqlalchemy in c:\users\{user}\appdata\local\continuum\miniconda3\lib\site-packages (1.2.15)
What obvious thing am I missing here that needs to happen for me to use these packages and modules?
EDIT:
python --version
Python 3.7.1
pip --version
pip 18.1 from C:\Users\{user}\AppData\Local\Continuum\miniconda3\lib\site-packages\pip (python 3.7)
However, I am using Anaconda for a virtual environment, and PyCharm as my IDE. I have included a screenshot of the projects interpreter for a good measure.Project Interpreter
Furthermore, I have checked that I have pip installed it on both the root and the environment.Root Environment
I think, you have multiple python versions installed.(2.* | 3.*)
You are installing packages in one python version and using another python version.
EDIT:
You can use pip2 install modulename for python2
and pip3 install modulename for python3
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!
I was trying to use the lmfit package for doing nonlinear least squares fit and I notices that the Canopy curated version is really old and doesn't have most of the objects. So I followed the instructions here https://support.enthought.com/entries/23389761 as I have done before no problem:
pip install --upgrade setuptools
pip install --upgrade lmfit
Now when I execute the same exact code some "import" statements (I suppose those involved with scimath) give:
ImportError: cannot import name scimath
Seems python standard library imports are fine e.g. import os.
I'm on Ubuntu Linux 14 with Canopy 1.5.2
What happened and how can I fix it and avoid breaking it again.
I solved the problem but I am still not sure why this occurred originally. I went into the package manager and uninstalled scimath reinstalled it and did explicit kernel restarts on my IPython notebooks and interpreters. This fixed it but I don't see why unless somehow the scimath installation was corrupted. Before that I tried restarting application, computer, and reinstalling canopy.
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