I have a program that imports a library called pyfits. When I compile the project, I get an error that says:
Traceback (most recent call last):
File "C:\Users\KenPreiser\Desktop\Space thing\Sample.py",
line 2, in
import pyfits
ImportError: No module named 'pyfits'
I have pyfits downloaded to my E:\ drive. Is this a problem?
Downloading a library to any folder on your system will not make it available for the python interpreter to import into other modules.
pyfits has instructions on how to install it. Preferred way to install any python package is using pip.
If you have downloaded the .exe of the library, install it like how you would install any windows program.
If you have downloaded the source instead, uncompress the source archive. And install it with commands:
python setup.py build
python setup.py install
This will install the library into python site-packages. If pyfits is installed correctly executing this command:
python -c 'import pyfits; print pyfits.__version__'
from your command prompt should display the version information of the library. Once you confirm that you have installed it correctly by doing the above, you can re run your sample.py
Related
I've installed the "openexr" package within my windows system. To do this, i used powershell from my blender installation folder "C:\Program Files\Blender Foundation\Blender 3.0\3.0\python" to launch the command ".\bin\python.exe -m ensurepip", for installing pip, and then "pip install openexer" to install the package.
Everything seems fine, but when I open blender and start to code with a simple
import openexr
I obtain this error:
Traceback (most recent call last):
File "\Text", line 1, in <module>
ModuleNotFoundError: No module named 'openexr'
Error: Python script failed, check the message in the system console
The module seems installed, but it's like blender cannot access it. Someone can help me? I would be extremely happy if this could work !
At the moment I tried to re-install pip or the openexr package, but the problem persist.
Also, if I try to re-install openexr, the system answer me that the package is already installed.
I am attempting to install a local directory as a python package, so as to make other modules in the package accessible to each other, similarly to how java files are able to access each other.
python -m pip list | grep sumobot returns:
sumobot 0.1 /home/pi/Documents/sumobot
However, trying to run a file in the package returns this error:
Traceback (most recent call last):
File "tests/test_motor.py", line 1, in <module>
from sumobot.robot_hardware.motor import RawMotor as Motor
ModuleNotFoundError: No module named 'sumobot'
I'd like to understand how this can be the case, as from my reading, installing with python -m pip should fix issues of wrong python versions. Also, if there is a better way to do what I am looking to do, please let me know.
If it makes a difference, I am running this on a raspberry pi zero, and the contents of my setup.py (which was placed in the same directory as my sumobot package) are as follows:
from distutils.core import setup
setup(name='sumobot',
version='0.1',
description='is a sumobot!',
packages=['sumobot'])```
I am trying to create an image processing program using convolutions. I need the package scikit-image, specifically this:
from skimage.exposure import rescale_intensity
I have repeatedly installed scikit-image using pip install scikit-image in my terminal (Mac). I did this in the folder where my convolutions.py file is located (is this what is meant by the PYTHONPATH?). However, I always get an error message:
Traceback (most recent call last):
File "Convolutions.py", line 6, in <module>
from skimage.exposure import rescale_intensity
ImportError: No module named skimage.exposure
How do I solve the problem?
make sure you are installing the package on the same version of python which you are running. On a mac, python by default runs python-2.7, and the command python3 runs python-3.x. Also, pip by default installs packages to python-2.7. To install them on python3 try running
python3 -m pip install scikit-image
or simply
pip3 install scikit-image
I need to install python wrapper for StanfordCoreNLP.
I have used git clone https://github.com/smilli/py-corenlp and also pip install pycorenlp and its showing success in both the cases, but when I run from pycorenlp import StanfordCoreNLP, its showing ModuleNotFoundError.
I checked its path if it installed or not. It is installed at "C:\Users\simra_000\Anaconda3\Lib\site-packages\pycorenlp" using pip
and using git clone also it is installed at "C:\Users\simra_000\py-corenlp"
from pycorenlp import StanfordCoreNLP
Traceback (most recent call last): File "", line 1, in
ModuleNotFoundError: No module named 'pycorenlp'
check if the module was installed by:
pip list
also you can add this code to install the module if it's not installed:
import pip
required_pkgs = ['pycorenlp']
installed_pkgs = [pkg.key for pkg in pip.get_installed_distributions()]
for package in required_pkgs:
if package not in installed_pkgs:
with suppress_stdout():
pip.main(['install', package])
also check the version of python that you are used to run the script and the version of pip, for example if you are using python3 and you install the module via pip (python2) the module was installed for python v.2 only
otherwise check the name of your script, so if the name of your script is pycorenlp.py the import will not work, and you need to change the name of your script
hope that helps you
I downloaded multiple modules (Discord API, cx_Freeze) (pip download, Windows 10) and now I wanted to use them.
But when I want to import them, it says there isn’t any module.
From my former Python using (before resetting computer) I‘ve added a pycache folder and it worked for one module. I‘m not able to reproduce it for other modules. What to do?
I‘ve only one Python version (3.6.5) on PC.
I‘ve checked the \site-packages folder and they‘re there.
If you are using python3 then try downloading the library using
pip3 install libname
but if you are using python2 then install the library using
pip2 install libname or just pip install libname
try with these command and reply
try installing your library using the command prompt in normal user and with the admin user so that you will get to know that what is happening and also if it is still not working then try installing the library into the same folder of your project using pip custom install command
pip install -t <direct directory> <package>
then use the import statement
For Example I used
pip2 install -t c:\Users\Nav\Desktop\projectss cx_freeze
then i imported the library using
#from cx_Freeze import setup, Executable
import cx_Freeze
from cx_Freeze import *
it worked.
Previously i was getting error like :
File "C:\Python27\lib\site-packages\cx_Freeze\__init__.py", line 10, in <module>
from cx_Freeze.finder import *
ImportError: No module named finder
After custom install it is working