Can't install module "Bio" in PyCharm/VirtualStudio, neither using cmd (Windows) - python

I'm new to using Python and after months of not using PyCharm and VirtualStudio. I needed to do some Python stuff. I don't know why, but I can't load and install any module.
I need Bio module and I can't install it:
enter image description here
I tried to install it by cmd command using:
C:\Python310\python.exe -m pip install Biopython
pip install Biopython
Other pip commands, but I got the same error
enter image description here
And this happened. I installed VisualStudio from Windows, but I can't install it yet.

Related

ModuleNotFoundError: No module named 'cv2' (only in vscode with venv)

When I try to install opencv-python I get the following error:
ModuleNotFoundError: No module named 'cv2'
I tried to install cv2 via these commands:
pip install opencv-python
pip install opencv-contrib-python
pip install opencv-python opencv-python-headless
python3 -m pip install opencv-python
pip3 install opencv-python --upgrade
However, the problem remains.
I have noticed that this problem occurs only in the virtual environment (venv) of VScode.
In fact, if I launch this code from the terminal it does not give me any error and it returns me the version of cv2
import cv2
print (cv2.__version__)
Reply -> 4.6.0
I use Python 3.9
EDIT:
This is a screenshot of the problem
The problem do not appear if I create a new venv
Use Ctrl+Shift+P to open the command palette search and select Python:Select Interpreter, then select the correct interpreter, this will solve your problem.
Tip: Every time you choose a new interpreter, please create a new terminal to activate the environment.
As far as your question is concerned, you can follow these steps:
Select the interpreter in the virtual environment according to the above method
Create a new terminal
Use pip install opencv-python to install the package
Also you can use pip show opencv-python to see where the package is installed.
What solved it for me was adding the following to the .vscode/settings.json config file
// Add venv to python path
"python.analysis.extraPaths": [
"${workspaceFolder}/venv/lib/python3.8/site-packages"
]
change venv to the name of your virtual env folder.

VSCodium not importing modules in Python

I wanted to make a voice assistant importing SpeechRecognition on Python;
I installed PyAudio and SpeechRecognition with the following commands: pip install PyAudio pip install SpeechRecognition on Linux, but when I try to import SpeechRecognition with import speech_recognition as sr, VSCodium doesn't import the module.
But then I tried to import other modules, and the same thing happens... what should I do?
You can check which pip you are using through pip --version, and which python you are using through where python(cmd) or get-command python(PowerShell). Make sure pip matches up with the python interpreter you are using.
If it's not, you can try to reopen the terminal with the shortcut 'Ctrl+Shift+`'. And then to check the pip version again.
If it still not matches up with the interpreter. That's maybe this environment hasn't installed the pip in this environment.
I think its main reason is on Linux pip is for python 2 while pip3 is for python 3.
If you are using py3 using pip3 may help. Other reasons may include a virtual environment you are on.If vscodium does not automatically activate it or whatever extension you are using do not run in the virtual environment it may not find the packages you installed. you can try these commands:
Example:
pip3 install PyAudio
pip3 install SpeechRecognition
python3 main.py

Python 2.7: No module named setup tools

I am trying to clone and install the keras package from github. When I run sudo python setup.py install, it says no module named setuptools. I looked at some posts that were for python 3; however, this solutions did not work for me. I am working on a terminal from a windows computer. I am using python 2.7. I tried the following commands: python -m pip install -U pip setuptools from this website: https://packaging.python.org/installing/. However, nothing seemed to work.
If you are working on Windows then you should be typing batch commands, not bash (Linux, OSX), therefore, sudo ... should not be used by you.
Firstly, I would recommend to install pip, it will make package update and installation a lot easier. Save it as get-pip.py and run the following in the directory the file is located python get-pip.py. Official pip website.
Then install upgrade pip which will also install the latest versions of setuptools and wheel with this python -m pip install -U pip setuptools.

"no module named PyPDF2" error

I use Spyder, with Python 2.7, on a windows 10. I was able to install the PyPDF2 package with a conda command from my prompt. I said installation complete. Yet, If I try to run a simple import command:
import PyPDF2
I get the error:
ImportError: No module named PyPDF2
How can I fix this?
In my case, I was trying to import 'pyPdf2' instead of 'PyPDF2'. Observe the case.
import PyPDF2
is correct.
If you use python3 maybe
apt-get install python3-pypdf2
I faced the same problem. But, In my case,
I previously installed Python3 separately from official website and was using without any issues
Then later I installed Anaconda package distribution software which itself has another Python3 installed in corresponding directory.
So, when I installed PyPDF2, it installed normally and while importing throws an error, because the base path of python3 was changed to be used with Anaconda.
Then I opened Anaconda prompt and installed PyPDF2 there and tried to import. It worked!!
Then I can use it from any command prompt in my Windows PC. Or else you can delete Anaconda and everything works normally. Its just a conflict of two pythons in my pc.
Conclusion: Try any overlapping softwares in your PC(in my case Anaconda prompt) and try their CMD to install packages and import. If I wanted to install any package I have to go to Anaconda prompt and install it and importing that modules works anywhere without any error. So from now on wards I'm only using Anaconda prompt as my default installation prompt.
This is the case which I followed for python3. For python2 try with pip:
pip install PyPDF2
I had this problem too when I tried to import PyPDF2 like this:
sudo apt-get install python-pypdf2
When running some simple script with import PyPDF2, I would get an error like this:
ImportError: No module named PyPDF2
The solution was to also install pdfmerge, like this:
pip install pdfmerge
How to install Python packages on Windows, Mac, and Linux for various versions of Python which are simultaneously installed:
I have multiple versions of Python installed on my Windows 8.1 machine (Python 2.7, 3.5, and 3.7). This created problems (confusion, I should say). You must therefore be very explicit when installing packages. Ex:
py -3.7 -m pip install PyPDF2 # on Windows
python3.7 -m pip install PyPDF2 # on Mac and Linux
INSTEAD OF the more generic:
pip install PyPDF2 or
pip3 install PyPDF2
And to upgrade pip, be very specific in your python version, like this:
py -3.7 -m pip install --upgrade pip # on Windows
python3.7 -m pip install --upgrade pip # on Mac and Linux
INSTEAD OF the more generic:
py -3 -m pip install --upgrade pip # on Windows
python3 -m pip install --upgrade pip # on Mac and Linux
Now, I can run python 3.7 with py -3.7 on Windows, or with python3.7 on Linux, and since I did py -3.7 -m pip install PyPDF2 on Windows, or python3.7 -m pip install PyPDF2 on Linux or Mac, the import PyPDF2 command works! Previously, since I had only done pip3 install PyPDF2, the import PyPDF2 command only worked if I ran py -3.5 on Windows or python3.5 on Linux, oddly enough, since apparently that was my "default Python3 version" which the more generic pip3 install PyPDF2 command must have installed the PyPDF2 module into. I think it has something to do with the fact that I installed Python 3.5 for all users, but Python 3.7 for only my user account, so the different pip install commands were placing the installed packages into different locations, with the 3.5 version being the "default" Python3 install location.
See more here: https://docs.python.org/3/installing/index.html:
... work with multiple versions of Python installed in parallel?
On Linux, Mac OS X, and other POSIX systems, use the versioned Python commands in combination with the -m switch to run the appropriate copy of pip:
python2 -m pip install SomePackage # default Python 2
python2.7 -m pip install SomePackage # specifically Python 2.7
python3 -m pip install SomePackage # default Python 3
python3.4 -m pip install SomePackage # specifically Python 3.4
Appropriately versioned pip commands may also be available.
On Windows, use the py Python launcher in combination with the -m switch:
py -2 -m pip install SomePackage # default Python 2
py -2.7 -m pip install SomePackage # specifically Python 2.7
py -3 -m pip install SomePackage # default Python 3
py -3.4 -m pip install SomePackage # specifically Python 3.4
When using pip, it usually gets installed in Python 2+ so try
pip3 install PyPDF2
I had the same issue and fixed it when switching Python compiler (bottom left corner on Visual Studio Code) . Try on different versions and eventually it should work.
Im following a UDEMY course here. Im using Anaconda prompt and jupyter notebook.
I encountered the same issue as OP. What I did to have the library working:
restart the environment
go to your anaconda prompt
control c to stop the running instance
conda activate ***your_env_here***
pip install PyPDF2
(in my case open the jupyer notebook) jupyter notebook
You can now import the library without the error. import PyPDF2
Hope this works for you.
I encountered the same issue today while doing Udemy course.
try the following:
type this
import sys
!{sys.executable} -m pip install PyPDF2
then
import PyPDF2
Hope it works for you too.

Error in Installation of Module

I'm trying to install the module zipline into Python 2.7 on Eclipse. I'm running the file with the following but the Error SyntaxError: invalid syntax results. I need help figuring this out.
import pip
pip install zipline
Edit: I have tried pip install zipline on the Command line as seen in the picture below but to no avail.
pip is a linux command, not a [tag: python] command. Thus, exit from the python interpreter and run the pip install in your Linux interpreter and it will run fine.
After installation, open your python interpreter and run
import zipline
And it should run fine.
You need to run pip install from the command line. Please note you also need to install numpy.
Run in command line
pip install zipline
OR
sudo pip install zipline
if any permission issues
Then in file, just import it
import zipline

Categories

Resources