My python version is Python 2.7.17
I usually use pip to install other modules like shutil and itertool etc. I can't find the package name for os, getopt and sys modules.
Any help will be appreciated.
Thank you.
Python 2.7 is obsolete and no longer supported (as of 1 January 2020). You should consider using the latest version (currently Python 3.8.5). For more information, see this.
The modules you are looking for are core modules of standard Python distribution, therefore they are installed when installing Python itself.
They are installed with your python as part of the standard library, if they are missing, something is wrong with your Python installation and you should reinstall it
Related
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 am running Python 2.7.9 on a Windows 8 machine. I've programmed for a long time (since the 60s), but I'm having trouble figuring out how to install the Six Module. I need a step-by-step set of instructions. Either help here or a suggested website would be helpful to this old man. Thanks!
On some computers where I don't have pip installed I usually do:
Extract the downloaded file
In the command line, where you extracted do python setup.py install
Module should now be installed
You can run python now
In the interactive interpreter do import module_name
If you get no errors, installation was a success
In Python 3.4 from Anaconda, I created a program and it is giving me and import error each time I run it.
Using Spyder.
ImportError: No module named 'win32api'
I already have the pywin32 installed. And I can see the win32api.pyd under C:\Anaconda3\Lib\site-packages\win32
This is the import code on my program:
from tkinter import *
from tkinter import ttk
import tkinter.messagebox
import time
import requests #needs to be installed
import pymysql #needs to be installed
import csv
import win32com.client #needs to be installed
import datetime
This is the whole error:
File "C:\Anaconda3\lib\site-packages\win32com\__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: No module named 'win32api'
This is the only instance of Python I have installed. I uninstalled everything else and installed only Anaconda.
Searching online I got to something that said that it could be a problem with the PYTHONPATH. But honestly, I have no idea what they are talking about.
So any noob help would be really appreciated.
I am using Windows 7 by the way.
Thank you
The installation for pywin32 must have failed, or it is not for same OS bit architecture (say anaconda 64 bit and pywin32 32 bit). I recommend
you uninstall pywin32,
check what bit version of anaconda you are using, then
install pywin32 for same version,
verify that the installer indicates 100% success and there are no errors flagged in the installer's log window (it's rare but something may fail and the installer doesn't know).
Then open a python console and type "import win32com".
If #5 fails to import win32com, then:
try installing a different version of python, for example from python.org
repeat steps 2 to 5 above but for new python instead of anaconda
Could be that anaconda distributors did something to the python interpreter (although I didn't think so), or that some libs aren't registered right (see answer https://stackoverflow.com/a/17061853/869951 for some more things to try).
This should work:
pip install pypiwin32
I had the same problem and solved it installing the module pywin32:
In a normal python:
pip install pywin32
In anaconda:
conda install pywin32
My python installation (IntelĀ® Distribution for Python) had some kind of dependency problem and was giving this error. After installing this module I never more saw it.
As mentioned by outforawhile in comment, simply restarting the laptop fixed this for me.
It may be that this is required for Windows to register the DLL.
try this before install pywin32
pip install pywinutils
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.
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