A similar problem with the python gdal module Gdal will not import after several installs (Mac OSX) was solved by modifying my shell profile to ensure MacPorts-installed ports are found, and then using sudo port select python python27.
But this time it's every module in my graphics folder that deals with tiff and png reading and writing that will not import:
tiff #3.9.5 graphics/tiff
pngpp #0.2.3 graphics/pngpp
libgeotiff #1.3.0 graphics/libgeotiff
Again, when I run python to import either module I get the similar response:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named png
What am I doing wrong?
For most Python packages, MacPorts has separate ports available for each supported Python version. For example, if you are trying to use PIL (the Python Imaging Library), you need to install the 2.7 version of that port:
sudo port install py27-pil
That will also install the MacPorts version of Python 2.7, if you don't already have it installed. It is located at /opt/local/bin/python2.7.
Related
I created .exe file using pyinstaller 3.3.1 and I got this message
Traceback (most recent call last):
File "install.py", line 14, in <module>
ImportError: No module named configobj
[8468] Failed to execute script install
I'm working with python 2.7 using conda environment. Lately I had updated pyinstaller to version 3.3.1 so this happened to me while I'm checking that the update is safe.
I have also created another .exe file from different script that uses also this import and its went well, so any help will be welcome.
I got this error from certbot on Ubuntu 20.04 (focal). On this version of Ubuntu, python 2 seems to be mostly deprecated and many things don't work when using it. Everything needs to be configured to use python3.
When I ran certbot, it was still using python 2.
File "/usr/local/lib/python2.7/dist-packages/certbot/main.py", line 9, in <module>
import configobj
ImportError: No module named configobj
Python 2 pip is no longer available from apt on this version of Ubuntu, so I was not able to install the proper libraries for python 2 using pip.
The version of certbot in apt is supposed to be for python3. (python3-certbot). The executable for certbot gets installed at /usr/bin/certbot.
After further investigating, I found that I had an older python 2 version of certbot hanging around at /usr/local/bin/certbot. Once I removed that (sudo rm /usr/local/bin/certbot), the python3 version of certbot runs just fine and is able to find all its libraries.
You need to install configobj via pip apt install python-pip
I use this tutorial text as an example, there are others:
#!/usr/bin/python
import MySQLdb
If it produces the following result, then it means MySQLdb module is not installed −
Traceback (most recent call last):
File "test.py", line 3, in <module>
import MySQLdb
ImportError: No module named MySQLdb
To install MySQLdb module, use the following command −
For Ubuntu, use the following command -
$ sudo apt-get install python-pip python-dev libmysqlclient-dev
I have gone trough these steps, more or less as described above.
Problem is that the subdirectory "python" does not exist under /usr/bin/
in my file system. I run Linux Mint 18.3. Python 2.7 seems to be the native version installed in Mint (used for several purposes), but I have also installed Python 3.6.4 and wish to use this for development purposes.
Does anyone know in which directory I could expect to find MySQLdb?
Since #!/usr/bin/python is non existent I wonder - has MySQLdb been properly installed? If it has, I have not after several efforts succeded in locating it.
I want to import the vlc from my python script, but it is getting error like follows:
Traceback (most recent call last):
File "test.py", line 3, in
import vlc
ImportError: No module named vlc
How to solve this problem??
For people stumbling upon this answer in 2020 and using Debian Linux, try the following command:
sudo pip3 install python-vlc
looks like your files are not on "sys.path", from where usually python tries to pick up imports
Try and access from interpreter. just type "import vlc" and see if that works.
If it does't work then just copy your vlc module files (I guess its vlc.py) to your python sys.path location and try again
go through these links, it may help
https://docs.python.org/2/using/cmdline.html#environment-variables
https://docs.python.org/2/library/sys.html#sys.path
Try to use pip install python-vlc in command prompt (if you are using windows). This will remove that error, as vlc is not yet installed on your system.
If you are using Ubuntu or other Linux Kernel OS, then first install pip (and python) on your system using whatever your package manager is (if necessary), then do pip install python-vlc.
I installed the package python-gconf on Ubuntu 12.04 and played with it: it's a python binding to the gnome configuration tool, and there is no pypi package for it.
As soon as I created a virtualenv (without --no-site-packages), any attempt to import gconf would lead to ImportError.
The gconf module works fine at the system level, but not in the virtual env. I investigated, and opening python-gconf.deb teached me that it's just a gconf.so binary.
Searching for it tells me it's been installed in /home/lib/python2.7/dist-packages/gtk-2.0/gconf.so
I did try to force Python hands:
sudo ln -s /usr/lib/python2.7/dist-packages/gtk-2.0/gconf.so ~/.virtualenvs/appetizer/lib/python2.7/site-packages/
But it only resulted in:
>>> import gconf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: could not import gobject (error was: 'No module named gobject')
So I'm guessing it's very dependant to GTK.
You should create your virtualenv using --system-site-packages option to make all system packages visible. Symlinking external packages into virtualenv's structure also works for most situations when you need only one external package.
If you have already created your virtual environment, just remove the no-global-site-packages.txt file from it to make it see system packages.
I want to run wexpect (the windows port of pexpect) on my Windows 7 64-bit machine. I am getting the following error:
C:\Program Files (x86)\wexpect\build\lib>wexpect.py
Traceback (most recent call last):
File "C:\Program Files (x86)\wexpect\build\lib\wexpect.py", line 97, in <module>
raise ImportError(str(e) + "This package was intended for Windows like operating systems.")
ImportError: No module named win32console This package requires the win32 python packages.This package was intended for Windows like operatin
g systems.
In the code it is failing on the following line:
from win32console import *
I am using Python 2.6.4. I cannot figure out how to install win32console.
Install this: http://sourceforge.net/projects/pywin32/
Edit to add slightly longer explanation: There's a very useful set of Windows-specific Python modules, called PyWin32. I believe win32console is part of that. You can either install PyWin32 on top of the standard python.org release of Python, or you can install ActiveState ActivePython which bundles everything you need all together. I'm using ActivePython and I have a win32console module.
Install wexpect with pip to install all dependencies (inluding pywin32).
pip install wexpect