Whenever i download a module using pip or similar the modules go to my python2.7 folder instead of my python3.8 folder, and due to this whenever i run my code if there is a module not in my 3.8 folder which is in my code i get a ModuleNotFoundError,
eg just recently:
File "/Users/tvnsh/Library/Python/3.8/lib/python/site-packages/flask/app.py", line 34, in <module>
from . import cli
File "/Users/tvnsh/Library/Python/3.8/lib/python/site-packages/flask/cli.py", line 25, in <module>
import click
ModuleNotFoundError: No module named 'click'
I know i can just move it from the 2.7 to 3.8 but why is this happening?, and how do i get the modules to download straight to my 3.8 folder instead?.
PS im new to coding and python as a whole so I appreciate your help.
how do i get the modules to download straight to my 3.8 folder instead?.
You might make sure you are downloading to your current version of python (i.e. what is launched after typing python) by doing
python -m pip install click
and for python3 (version which is launched after typing python3) by
python3 -m pip install click
If you want to know more read Installing Python Modules.
If you are creating a virtual environment, the easiest way is to run
pipenv --python 3.8
Alternatively and as a more persistent solution, you can add the following lines into the pip file:
[requires]
python_version = "3.8"
You are probably using the wrong version of pip.
Check if you have something called pip2 for python 2.x and pip3 for python 3.x
Otherwise using something like pipenv to not install all dependencies globally would probably be the most recommended option
Related
I have been having many issues with my python on macOS
(Im a beginner)
I want to use modules but every time I install something it says that the module doesn't exist even though its already installed I think it might be cause of the many versions of Python
python3 -- version says python 3.10.8 pip3 --version says python 3.9 (system) I have python 3.11.1 it does not work. In vscode I want to use packages I install them it says they don't exist. I change my VS-code python to all the different versions they still say they dont exist. I install the packages it says they already exist
from fastapi import FastAPI (, Request)
from fastapi import FastAPI, Request
ModuleNotFoundError: No module named 'fastapi'
I have tried using pyenv to manage versions and it says everything is on 3.11.1 but it doesn't change anything i have tried to remove the other versions of python but has been unsuccessful
Your terminal python, your vs-code terminal python and your project interpreter python could be diverse depends on how you install python.
To keep it simple, keep them watch same python.
On your terminal, go to your project root directory.
Type,
python -m virtualenv .venv
Virtualenv has created named '.venv'.
On terminal type source .venv/bin/activate to activate created python.
Now, your terminal python is same as your .venv.
Install all your dependency by hitting pip install -r requirements.txt
On your IDE, vs-code, set python interpreter to your ~/project/path/.venv/bin/python.
Now Every python see same python.
I'm trying to install packages on multiple versions of Python. I'm currently running 3.8.8, and 3.11.0.
Following this post Install a module using pip for specific python version
called
python3.11 -m pip install pandas
which results in
File "<stdin>", line 1 python3.11 -m pip install pandas SyntaxError: invalid syntax
This seems to indicate an issue with python, so I double checked that python3.11 is installed.
the python3.11 works in isolation seems to work.
I don't understand why the install command isn't working.
If you’re using Linux try just
python3 —-version
In Windows you may need to add path to folder with installed Python to PATH variable.
Check your environment variables, you could try removing the variables pointing to the 3.8 version until you get the packages you want installed.
You could also try navigating to that python 3.11 installation directly, and executing the python shell from there, then run the command.
I am using Ubuntu Server 18.04 LTS(HVM)-free tier to run my python script. I connect with the Key to the server with Putty. I manage my files loaded onto the the server using FileZilla. After I install python on the server with sudo apt install python3 I install Selenium using pip install -U selenium. The process is a success. I then load my python script through FileZilla and then try to run the python script. Like most that have asked I get the error:
Traceback (most recent call last):
File "BinaryAutomation.py", line 1, in <module>
from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'
Now please understand this. I have tried to install selenium manually by installing and unachieving the file found here, which basically downloads the setup to be loaded using python setup.py install. I do not have permission to paste anything under tmp\usr\bin I have tried that. How do i get around this problem?
You probably have other versions of python/pip installed. Install packages using pythonx -m pip install ... with pythonx your python version (python3 I presume) to avoid installing packages for a version of python that you're not using to run your scripts.
For more details check: Why you should use python -m pip - Snarky
Ubuntu generally follows PEP 394, which says that the command python should be Python 2. So, use python3 instead of python. That extends to PIP too, so I would say to use pip3 instead of pip, but that method is becoming outmoded; use python3 -m pip instead.
This is assuming you haven't changed the python and pip commands.
I've installed a module named rauth through terminal with pip3 install rauth command but when I import the module and run the code on Visual Studio Code with python3 interpreter, it gives ModuleNotFoundError: No module named 'rauth' error. But it is indeed installed and I can use it in Anaconda. The package file is stored here.
/Users/puffedricecracker/anaconda3/lib/python3.7/site-packages/rauth
And it seems like all my pip installed packages are stored in that path, but those are imported outside Anaconda with no problem. Tried several other commands as google search suggested.
• pip install instead of pip3 install
• python -m pip install
• python3 -m pip install
Let me know if there is any other information needed to be specified.
this is due to the module is installed into site-packages in Anaconda but not Visual Studio. Can you check if the module exists in Visual Studio folder? Another way to test it is to open Python IDLE and run the import, it should also return an error.
I don't know if this could be an universal solution but there was a way to set where to install a package using pip.
In python shell, find where your python modules usually go. It seemed like most of pip installed packages were installed in the second path so I chose that.
>>> import re
>>> print(re.__file__)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/re.py
>>> import sqlalchemy
>>> print(sqlalchemy.__file__)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sqlalchemy/__init__.py
Uninstall the package using pip uninstall packagename
Reinstall with a path name.
pip install packagename -t /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
(In fact, just copy pasting package files (in my case, they were rauth, rauth-0.7.3.dist-info) from anaconda package path in the post worked.)
I've installed python 3.4 on win7. I need faker module to be installed to run the script.
error:
from faker import Factory
ImportError: No module named 'faker'.
I've downloaded few zip's with faker, but unfortunately have no idea how to install it.
Please give simple instructions, how to make it work.(on windows)
Since you have downloaded the zip source from https://github.com/joke2k/faker according to your comments , you can also do the following after changing to the directory where you have setup.py -
python setup.py install
According to the github page itself, to install using pip do -
pip install fake-factory
Use the Python package tool pip.
Open a command prompt and do
pip install fake-factory
or
python -m pip install fake-factory
See the documentation for more information.