I have my venv activated but still pip installs packages in another folder.
(venv) C:\Users\JB\PycharmProjects\Flask_project>pip install marshmallow
Requirement already satisfied: marshmallow in c:\users\JB\documents\anaconda\lib\site-packages (3.10.0)
My guess is that you are using a command that changes the location of your instalation directory. Another thing I can assume from the problem you are having is that the packages are already installed on your venv, can you please test it ?
Okay, the problem was I had some manual packages which were imported, and was causing problem, creating another venv solved the problem.
Related
No module named PyEmu
PIP:
C:\Users\TEST\Desktop\New folder>pip install pyemu
Requirement already satisfied: pyemu in c:\python37\lib\site-packages (1.2.0)
Installed pyemu still showed this error
It's best to work in a virtual environment. So you can know the problem and work in a more orderly way.
You can create a virtual environment in Windows with virtualenv:
virtualenv envname -p python3
Then you must activate it:
envname\Scripts\activate
Then, install your packages in isolation. If you're still getting errors, you may need to install older versions of the package (and update this issue with your code).
So I have a virtual environment set up in VS Code. I recently learned that it's better this way because it doesn't interfere with my global python data. The problem is that I'm still getting issues. When I try to install a package in that environment using pip, it gives a message like this and it doesn't install:
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: {PACKAGE NAME} in c:\users\lavaa\appdata\roaming\python\python311\site-packages
I activated the environment and selected it as my interpreter before this.
This confuses me because why should it care about that python directory when I'm in a virtual environment? It's not already installed in the virtual environment, so there should be no problem, right? I didn't want to mess anything up, so here I am.
One last thing: When I went to the appdata directory to find the issue, I saw that the package was installed there. I don't know why it didn't get placed in the virtual environment folder.
If you use pip command to install, the package will be installed in pyenv.
If you are using conda environment you can use the following command to install:
conda install packageName
You can read document about environment for more information.
I want to install a few modules - the problem here is, i already have those modules in a virtual enviroment, so i get the
Requirement already satisfied error.
How do i avoid this? Is there a way to force PIP to download a package, even if it already exists somewhere on my system? And why does this error even come up when im PIPing outside of the venv?
I could paste the modules manually into my normal python folder, but i thought that there has to be a simple method - of course, i could just unmount the entire hard drive where the venv is located on...
a. If you want to reinstall a package you can always uninstall the package and reinstall it with the following.
pip uninstall requests
pip install requests
b. If you are seeing "Requirement already satisfied" inside of your vanilla python installation then it must already be installed there. You can check the packages that are installed by running the following. (you can run this on your virtual environment and your vanilla python installation to compare the results)
pip freeze
defusedxml==0.5.0
isodate==0.6.0
lxml==4.2.1
pkgconfig==1.3.1
python3-saml==1.4.1
six==1.11.0
xmlsec==1.3.3
I'm trying to setup my environment for a project but python isn't able to find the modules I've installed with pip.
I did the following:
mkdir helloTwitter
cd helloTwitter
virtualenv myenv
Installing setuptools, pip, wheel...done.
source myenv/bin/activate
pip install tweepy
Collecting tweepy
Using cached tweepy-3.5.0-py2.py3-none-any.whl
Collecting six>=1.7.3 (from tweepy)
Using cached six-1.10.0-py2.py3-none-any.whl
Collecting requests>=2.4.3 (from tweepy)
Using cached requests-2.11.1-py2.py3-none-any.whl
Collecting requests-oauthlib>=0.4.1 (from tweepy)
Using cached requests_oauthlib-0.6.2-py2.py3-none-any.whl
Collecting oauthlib>=0.6.2 (from requests-oauthlib>=0.4.1->tweepy)
Installing collected packages: six, requests, oauthlib, requests-oauthlib, tweepy
Successfully installed oauthlib-2.0.0 requests-2.11.1 requests-oauthlib-0.6.2 six-1.10.0 tweepy-3.5.0
When I try to import the module it says it cannot be found.
The first entry in $PATH is helloTwitter/myenv/bin
All the packages are showing up in the environments site-packages directory.
I seem to be using the right python and pip.
Which python outputs helloTwitter/myenv/bin/python
Which pip outputs helloTwitter/myenv/bin/pip
Any advice on where I'm going wrong?
It looks like you're manually setting your $PATH to point to your virtual environment. The whole point of the myenv/bin/activate script is to take care of this for you.
Once you have activated your virtual environment, any package you install using pip will be placed in the relevant venv site-packages directory (in your case, myenv/lib/python2.7/site-packages). Things like pip --user are unnecessary when you are working in a virtual environment (assuming default behaviour). It's all automatic.
After running activate, you can check the python binary you are using with find -iname tweepy.
Aliases can cause issues too. which is an external command, and won't always pick these up. A type -a python will flush these out.
A quick test can be done by running helloTwitter/myenv/bin/python -c 'import tweepy' directly. If this behaves differently to however you are currently running python (i.e. doesn't throw an import exception), then this is your problem.
Hope that helps.
Ok, I think I found a solution, if not an answer.
I uninstalled the package and made sure it was not in system or user.
I re-created the virtual environment.
I checked that the environments python and pip were being used.
This time when installing my package I added the --no-cache-dir option. The packages install successfully. Now Python can find the package.
derptop:environmentScience Marcus$ python
>>> from tweepy import StreamListener
>>> StreamListener
<class tweepy.streaming.StreamListener'>
I checked the sys.path and it now includes the site-packages directory from the virtual environment, where previously it was absent.
Output of sys.path:
['', ....'/Users/Marcus/CodeProjects/environmentScience/myenv/lib/python2.7/site-packages']
As far as I can tell the sys.path was referencing the wrong site packages directory. Though I'm not sure why. I'm wondering if pips use of the cache was causing the site-packages reference to reset to system.
On Windows, if you are experiencing this issue, check that after activating your environment, the subsequent python commands are being run using the binary in the .venv\Scripts\Python executable.
I've seen this strange behaviour where even after the environment is activated using the activate.bat file in the virtual environment, AND the path to the Scripts\ directory is added to the system path, python commands still use the binary in the central Python installation in the system.
This leads to any packages being installed being installed NOT in the virtual environment, but in the global system location.
To work around this, when running pip or python commands after activating your environment, specify the correct path to the executable within your virtual environment, i.e.,
.venv\Scripts\python -m pip install setup.py
This should install the packages into the virtual environment and solve the issue.
I solved this problem by change project directory. Move your project directory from desktop to another place. It helped me on Windows. I moved it from /Desktop to C:/some_folder
I just re-installed python & virtualenv after accidentally getting everything messy. I noticed that my requirements.txt in my newly created environment automatically includes wheel==0.24.0. Is this normal, and what is it? I understand that virtualenv should create new environments without any system-installed packages.
I came across this issue when setting up virtualenv in windows.
To avoid wheel from being installed you can use the --no-wheel option.
virtualenv venv --no-wheel
To my understanding wheel is used handle a compressed format of a python package (.whl) that can be used by pip to speed up the install time. https://wheel.readthedocs.org/en/latest/
Probably one of the itens listed in your requirements.txt needs wheel package installed to work.
Although it's a common (and good) pratice list the fundamental python packages of a project inside requirements.txt, not all of the packages the eventually will be installed are there.
Your pip log may helps you to point what package required wheel to be installed.