I have already installed "PySimpleGUI" library, but I can't import it. In my terminal window I typed:
pip install PySimpleGUI
And it worked, because I typed it again and received this message:
PS C:\Users\raulc\AMBIENTES> pip install PySimpleGUI
Requirement already satisfied: PySimpleGUI in c:\users\raulc\appdata\local\programs\python\python310\lib\site-packages (4.59.0)
However, I can't import it, that's what i get:
Import "PySimpleGUI" could not be resolved
Related
Basically I am trying to run some simple code in sublime text 3 but when I try to run it it gives me the following error:
File "/Users/ingodavila/Desktop/My Programming/scrape.py", line 1, in <module>
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
I have tried installing it with pip3 and easy_install but it does not work. Whenever I try installing it it in terminal it keeps showing:
Requirement already satisfied: bs4 in ./opt/anaconda3/lib/python3.8/site-packages (0.0.1)
Requirement already satisfied: beautifulsoup4 in ./opt/anaconda3/lib/python3.8/site-packages (from bs4) (4.9.1)
Requirement already satisfied: soupsieve>1.2 in ./opt/anaconda3/lib/python3.8/site-packages (from beautifulsoup4->bs4)
I tried running it in a jupyter notebook and it works but for sublime it keeps showing that 'nomodulefound' error. What can I do to solve this?
Are you running the code inside a virtual environment?
If you are, try this method:
activate the env
install the module (inside the virtualenv)
run the code.
If the above doesn't work, try:
conda install bs4
It is probably because your Sublime text interpreter is different than your global one. I would recommend you using virtual environment instead of just installing modules globally. Check this one out on how to create venv. Once you set up your virtualenv and active it, you can just install packages and use them without any problem.
When I do:
import xgboost
I get no module named xgboost
I tried:
pip install xgboost
and i get:
Requirement already satisfied: xgboost in e:\anaconda\lib\site-packages (1.0.2)
Requirement already satisfied: numpy in e:\anaconda\lib\site-packages (from xgboost) (1.18.1)
Requirement already satisfied: scipy in e:\anaconda\lib\site-packages (from xgboost) (1.4.1)
versions
Python 3.7.4
pip 20.0.2 from E:\Anaconda\lib\site-packages\pip (python 3.7)
Where python:
E:\Anaconda\python.exe
C:\Users\Federico\AppData\Local\Microsoft\WindowsApps\python.exe
Usually this will happen because
You installed the package in a virtualenv and are trying to import it outside of the env
You installed the package globally and are trying to import it in a virtualenv which does not inherit the global packages
Your pip is linked to a different version than the python you're using
Based on the output of the where python it seems like you probably used the pip from anaconda to install the package, but are trying to import the package in a script that you're running with the python located here C:\Users\Federico\AppData\Local\Microsoft\WindowsApps\python.exe rather than here E:\Anaconda\python.exe
If your code with the import is in a script called test.py, for example, try running it with E:\Anaconda\python.exe test.py and see if the error still occurs
Or start a Python shell with E:\Anaconda\python.exe and then execute import xgboost in the shell and see if that works
I am able to install PyQtChart without error using pip, but I cannot import it as Python (3.7.3) tells me there is no such module.
I'm using Anaconda's Python distribution on Windows 10, but its version of PyQt5 is really old. After seeing a question with a comment by eyllanesc I uninstalled PyQt5 from Anaconda and reinstalled (the current 5.13 version) via pip. Everything with that worked fine and my PyQt5 is the latest version and imports and works well. But PyQtChart isn't importing. I installed like this:
OK> pip install --user PyQtChart
Collecting PyQtChart
Downloading https://files.pythonhosted.org/packages/a2/4c/2bf0482300e6ae407d33fcc098c310de00a86f3ee0755ae5419298e5e5c3/PyQtChart-5.13.0-5.13.1-cp35.cp36.cp37.cp38-none-win_amd64.whl (848kB)
|████████████████████████████████| 849kB 6.4MB/s
Requirement already satisfied: PyQt5>=5.13 in d:\programdata\anaconda3\lib\site-packages (from PyQtChart) (5.13.1)
Requirement already satisfied: PyQt5_sip<13,>=4.19.19 in d:\programdata\anaconda3\lib\site-packages (from PyQt5>=5.13->PyQtChart) (4.19.19)
Installing collected packages: PyQtChart
Successfully installed PyQtChart-5.13.0
OK> pip list
Package Version
---------------------- ---------
...
PyQt5 5.13.1
PyQt5-sip 4.19.19
PyQtChart 5.13.0
and when I import I get the error:
ModuleNotFoundError: No module named 'PyQtChart'
I also looked through the dir(PyQt5) and there is no submodule or component for charts.
How can get this to import properly?
EDIT:
As I mentioned, I already looked for other modules. This code is not helpful, but requested.
import PyQt5
import PyQtChart as qtch
#from PyQt5 import QtChart
d = dir(PyQt5)
for i in d:
if "chart" in i.lower():
print(i)
I TRIED multiple ways to install and import, including the suggested ways. Pip3 would not install the module.
You have to have the same version of PyQt5 and PyQtChart installed:
python -m pip install PyQt5==5.13 PyQtChart==5.13
TL; DR;
PyQt is a wrapper of the Qt, and each version of Qt generates .dll/.so that are not compatible with other versions. So that same problem moves to PyQt. In your case it is observed that the PyQt5 and PyQtChart libraries use different versions of Qt generating incompatibility.
On the other hand that a module is called X does not imply that it is imported using: import X, in the case of PyQtChart you should use: from PyQt5 import QtChart.
For me: only "pip install PyQtChart" this update PYQT5 and install module PyQt5.QtChart
I've installed openpyxl from the Terminal using
pip3 install openpyxl
without any problems. I've even double-checked by simply running import openpyxl from the Terminal window once Python is running, and it imports no problem.
The problem starts when I try and import openpyxl from a script I'm building to work with a spreadsheet. I'm using Sublime Text and can't even get past the import openpyxl at the beginning of the script without running into the following error:
Traceback (most recent call last):
File "/Users/wcw/Desktop/test.py", line 1, in
import openpyxl
ImportError: No module named openpyxl
How can this be happening? I know I've installed openpyxl correctly from the Terminal window without any errors so how can my script not find the module?
Try to do:
pip3 install --user openpyxl
Doing the --user worked for me when I tried to run my .py files with matplot lib modules which worked in 3.5 but not in 3.6.
I have the same problem.
I've installed the openpyxl succesfully via Anaconda
!pip3 install --upgrade openpyxl
Collecting openpyxl Using cached
https://files.pythonhosted.org/packages/95/8c/83563c60489954e5b80f9e2596b93a68e1ac4e4a730deb1aae632066d704/openpyxl-3.0.3.tar.gz
Requirement already satisfied, skipping upgrade: jdcal in
/Users/a18301335/Library/Python/3.8/lib/python/site-packages (from
openpyxl) (1.4.1) Requirement already satisfied, skipping upgrade:
et_xmlfile in
/Users/a18301335/Library/Python/3.8/lib/python/site-packages (from
openpyxl) (1.0.1) Installing collected packages: openpyxl Found
existing installation: openpyxl 1.8.6
Uninstalling openpyxl-1.8.6:
Successfully uninstalled openpyxl-1.8.6 Running setup.py install for openpyxl ... done Successfully installed openpyxl-3.0.3
But when I try to use tat library I get an error No module named openpyxl
import openpyxl
ModuleNotFoundError: No module named 'openpyxl'
If I try to import openpyxl in Terminal, I don't have the error. What's wrong?
This may be overly simplistic, but I had the same problem. I installed the module successfully but import openpyxl resulted in an error. I needed to close IDLE and start a new session. After that, my import command worked just fine.
I am working on a Macbook with Python 2.7.5 pre-installed. I installed the pandas package via command-line with the following code.
pip install pandas
This completed without errors. However, when I try to run the following code in Netbeans, I get an error.
if __name__ == "__main__":
import pandas as pd
The error is: ImportError: No module named pandas
When I try to re-install the pandas package in the terminal I get the message: Requirement already satisfied (use --upgrade to upgrade): pandas in /usr/local/lib/python2.7/site-packages
What am I doing wrong here?
Thanks for the help!