When I run the command:
pip3 install nltk
My terminal outputs:
Requirement already satisfied: nltk in ./Library/Python/2.7/lib/python/site-packages (3.4.5)
But when I load up python3, I get:
ModuleNotFoundError: No module named 'nltk'
This is driving me crazy, and I'm sure I'm missing something very basic, I just don't understand what!
Figured this out last week, but it requires moving the nltk package from the Python 2.7 library to the Python 3 library. If that's too difficult, another option is to delete the package in whatever location shows up and reinstall with
pip3 install nltk
Related
I'm reading the book "Python Crash Course" and I'm following along with the project alien invasion. I installed Python and the package Pygame as the book shows it.
When I run my code I get a ModuleNotFoundError:
ModuleNotFoundError: No module named 'pygame'
[Finished in 0.0s with exit code 1]
[cmd: ['python3', '-u', '/Users/antonio_spatuzzi/Documents/python_work/alien_invasion/alien_invasion.py']]
[dir: /Users/antonio_spatuzzi/Documents/python_work/alien_invasion]
[path: /Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
even though the package has been successfully installed:
``Requirement already satisfied: pygame in ./.local/lib/python3.8/site-packages (2.0.1)```
How can I solve this problem?
It seems that you installed the module for python 3.8 and you try to run it with python 3.9. Try installing the package with
python -m pip install
We can see from the output you posted that python3 is being used to run your programs:
[cmd: ['python3', '-u', '/Users/antonio_spatuzzi/Documents/python_work/alien_invasion/alien_invasion.py']]
So as was mentioned in an earlier comment, running python3 -m pip install pygame should install Pygame to the version of Python that you're currently using.
For beginners it's not a good practice to have two different versions of python installed. If you are on windows try to uninstall all versions of python. (maybe this helps: How to completely remove Python from a Windows machine?)
Then try installing the newest version of python and pygame.
In general, it's good practice to make a virtual environment with different instances of python and the respective packages used for a special project.
Maybe have a look into Anaconda
I'm using Python 3.7 and I recently upgraded to Spyder 4.2.0 from Spyder 4.1.5. Now when I run my code (which was working fine before) I get the following error:
ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.
So apparently Spyder thinks 'xlrd' ('Excel Reader'?) is not installed. So I went to the Anaconda prompt and tried pip install xlrd, but it replied with
Requirement already satisfied: xlrd in c:\users\michael\anaconda3\lib\site-packages (2.0.1)
I tried uninstalling and reinstalling xlrd anyways, using pip, but it didn't change anything. How do I resolve this error?
Also, I'm not sure if this matters or not, but I originally installed Spyder via Anaconda, whereas now I just downloaded Spyder 4.2.0 by itself, through this link: https://github.com/spyder-ide/spyder/releases.
Also, on the linked github page, it says: "If you are new to Python or the Scientific Python ecosystem, we strongly recommend you to install and use Anaconda. It comes with Spyder and all its dependencies, along with the most important Python scientific libraries (i.e. Numpy, Pandas, Matplotlib, IPython, etc) in a single, easy to use environment."
I had at first assumed this was meant for people downloading Python/Anaconda for the very first time, but now I'm thinking this applies to a semi newbie at Python such as me? As someone who is not very familiar with how packages and dependencies work, should I be downloading Anaconda every time I want to update Python or Spyder?
Apologies for the (probably) silly newbie question...
This sounds like you needed to re-start Spyder for it to pick up the package you installed.
However, as the author of xlrd, I would suggest you do the following:
Stop Spyder
conda install openpyxl
Start Spyder.
Change your pandas code to be pd.read_excel(..., engine='openpxyl')
I have created a virtual environment with python 3.6 and installed various packages using pip, when i do pip install tensorflow it says "Requirement already satisfied". However when i import it, I get No module name tensorflow.python
And as every guy should know the very first solution of every problem...
Uninstall and reinstall
Yep, It worked.
I am getting an import error in python when importing pyimgur. I have tried pip install pyimgur but still get the same error.
maybe it has a other name? look in the map site-packages. there you can find all your site packages. maybe like i say it can have a other name.
pyimgur supports for python 2.x, adding Python 3 to setup.py specifiers and also in pypi metadata. Else try to install with commands "pip3 install pyimgur"
in my Python Script there is an ERROR with the line
import win32events
I still installed the package pypiwin32 (with pip install pypiwin32) but it seems that this is nor the right package.
Does someone know what I need to install to use win32events in Python?
You should install pywin32 package (not pypiwin32)!!!