pip/python: normal site-packages is not writeable - python

I have a new Macbook - a user installed it, and then I installed a new user (mine), granted admin privileges and deleted the old one. I am on OS Catalina.
Since the installation I've been having several permission problems.
VSCode can't find Jupyter Notebook, pip installs packages at ~/Library/Python/3.7/site-packages.
When I do which python3 I get usr/bin/python3.
When I do pip3 install <package> I get: Defaulting to user installation because normal site-packages is not writeable And then it says it has already been installed, even though I can't access it when I do import <package>.
It's seems clear that this is a permission problem, pip can't install to the "base" python, and them python can't find what I've installed into ~/Library/Python/3.7/site-packages.
I've tried reinstalling the OS, but since I haven't done a clean install, it didn't change anything.
What am I missing?
How exactly can I fix permissions? Where do I want packages to be installed (venv sure, but some packages I want global (like jupyter).

As #TomdeGeus mentioned in the comments, this command works for me:
Python 3:
python3 -m pip install [package_name]
Python 2:
python -m pip install [package_name]

It's best to not use the system-provided Python directly. Leave that one alone since the OS can change it in undesired ways, as you experienced.
The best practice is to configure your own Python version(s) and manage them on a per-project basis using virtualenv (for Python 2) or venv, possibly via poetry, (for Python 3). This eliminates all dependency on the system-provided Python version, and also isolates each project from other projects on the machine.
Each project can have a different Python point version if needed, and gets its own site_packages directory so pip-installed libraries can also have different versions by project. This approach is a major problem-avoider.

python3.7 -m pip install [package_name]
(you should use the version that you have, of course)
solved it for me.
The most voted answer python3 -m pip install [package_name] does not help me here.
In my case, this was caused by a conflict with the dominating 3.6 version that was also installed as a default. You might ask yourself why you have 3.6 on your system, you will most probably not use that version now. The reason is that 3.6 is used as an independent default python version for many package installers. Those installers do not want to check which individual version you use and whether that fits, they just use 3.6 as a default, if you like it or not.
Here is a proof by example --upgrade pip:
pip3 install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in
/home/USERNAME/.local/lib/python3.6/site-packages (20.3.1)
python3 -m pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in
/home/USERNAME/.local/lib/python3.6/site-packages (20.3.1)
python3.7 -m pip install --upgrade pip
Collecting pip
Cache entry deserialization failed, entry ignored
Using cached https://files.pythonhosted.org/packages/ab/11/2dc62c5263d9eb322f2f028f7b56cd9d096bb8988fcf82d65fa2e4057afe/pip-20.3.1-py2.py3-none-any.whl
Installing collected packages: pip Successfully installed pip-20.3.1

I'm using Anaconda on Ubuntu and had the same problem.I fixed it by the following steps:
deactivating current environment
conda deactivate
Then, the base environment activates. I deactivated the base conda environment too. To do so, I used conda deactivate again.
Finally, I activate my project environment directly (instead of activating from the base environment) by the following command. Afterward, I installed the intended package successfully and worked perfectly.
conda activate myenv
pip install somepackage

sudo pip install
Worked for me. But pip install is not recommended to be run with sudo. The issue I was facing on BIGSUR was, it was using system python. Once I Installed python 3.9 using
brew install python#3.9
Then pip worked fine

For readers who thought themselves accidentally update system pip:
If you saw this info in your terminal output:
Defaulting to user installation because normal site-packages is not writeable
then you will be fine. Use the pip3 you just updated to run:
pyenv global system # since I use pyenv
pip3 uninstall pip # this one does the trick
Then you can check again pip3 --version will point to the original old (XCode/System-)pip. E.g. (2022/2/28):
pip 20.2.3 from /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)

It occurs with me when I the virtual enviroment folder name was : venv.
in this case, It gives errors like :
No module pip
Default folder is unwritable
renaming the folder solve the proplem.

Check on the command line "which python" to see if it is the value you expect.
If you have a virtual environment activated, check /venv/bin/activate to see the value of VIRTUAL_ENV= and make sure it is the correct path . The path may be wrong if you renamed or moved the project. If the path is wrong, you can delete the venv and make a new one.

For me, none of the suggestions worked so I had to delete the current virtual environment folder venv and recreate it using one of the following commands:
python -m venv venv
python3 -m venv venv
Check the source of pip on Ubuntu 20.04
which pip
returns the correct path
/home/myname/fullstack/person_api/venv/bin/pip
UPDATE
I presume that some might encounter this problem because they set python path as environmental variable like this in ~/.bashrc:
python=/path/to/python
which you should not be doing! Instead we could do:
py=python
PATH=/path/to/python:$PATH
I bumped into this issue specifically because of this!

Had this same issue on a fresh install of Debian 9.12.
Rebooting my server solved the issue.

In my case on Linux, the ownership of the conda env directory had changed to another Linux user (long story), and so the the normal site-packages was not writeable due to a permissions issue.
The solution was to change ownership back to the user doing pip install.

I met exactly the same issue.
I just type sudo python3.8 -m pip install .... and the error disappeared.
If I remove the sudo, issue remains.

For those running on a Pi, that accidentally installed pip as root. Just chown the lib folder to the pi user:
sudo chown -R pi:pi /usr/local/lib/python3.9/

in my case python3 -m pip install [package_name] did not solve that.
in my case, it was a problem related to other processes occupying the directory.
I restart Pycharm and close any other program that might occupy this folder, and reinstalled the package in site-packages directory successfully.

When this problem occurred to me I have tried all the mentioned approaches but they don't seem to work.
Instead, restarting Python language server in my VSCode did the job - my SimPy package is now found. On Mac it is Cmd+Shift+P and select "Python: Restart Language Server".

Had similar issue on Ubuntu 20.04.4 LTS in VirtualBox, but none of the suggestions here worked for me.
I was trying to install open3d in a venv and every time I was getting
"Defaulting to user installation because normal site-packages is not writeable"
which at first I didn't even noticed. open3d was always being installed in /usr/bin/python3 environment. I've restarted the VM but without luck, so I guess the problem was not just missing write access.
So in VS Code, which was using the venv, importing open3d was not possible. But testing from terminal from the activated venv with python3 -c "import open3d as o3d; print(o3d.__version__)" was working fine and that confused me totally. I even broke my system pip installation using sudo, see further below if you want to know how to fix it.
Anyhow, the solution to my problem was to explicitly point to the python3 file in the venv where I wanted to install the package:
venv/bin/python3 -m pip install open3d
So I was testing out everything and eventually installed with sudo: sudo pip3 install open3d. This of course didn't solved the problem and open3d was still missing in the venv. Even worse, I got the message:
"WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command."
So I did it but with sudo, updating the system pip and then found out here that this is not good:
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Following an advice here, I tried to revert to original version, only then pip3 broke:
sudo pip3 uninstall pip
sudo pip3 --version
sudo: pip3: command not found
The apt package was still there:
sudo apt install python3-pip python3-pip is already the newest version
(20.0.2-5ubuntu1.6).
So I had to reinstalled to fix the problem:
sudo apt-get remove python3-pip
sudo apt install python3-pip

Maybe you have python, python3, pip or pip3 aliased. In that case pip might not work well anymore, as the alias isn't always available and so pip/pip3 might resolve python/python3 differently compared to in your terminal.
That could give rise to pip/pip3 trying to install in the system python, and that could give rise to your error.

I tried ever single recommendation described here. In every instance, I get the exact same result: SyntaxError: invalid syntax (<stdin>, line 1)
I'm not sure who designed the system like this, but it seems basically useless, based on my experience so far. Either create a system that works, or don't create anything at all.

Related

Command 'pytest' not found even though I moved pytest.py to /bin [duplicate]

There are already two posts on stack overflow on this topic; however, none of them have resolved or addressed my specific situation.
I have installed pytest via pip install pytest. I am able to import the library in Python as well.
The problem is that when I try to use the py.test command in Terminal, I get py.test: command not found.
Does anyone have any insight as to why I am not able to use the command in the terminal?
EDIT: It even shows up as an installed package:
$ pip list
cycler (0.9.0)
matplotlib (1.5.1)
numpy (1.10.1)
pip (8.1.0)
py (1.4.31)
pyparsing (2.0.7)
pytest (2.9.0)
python-dateutil (2.4.2)
pytz (2015.7)
scipy (0.17.0)
setuptools (7.0)
six (1.10.0)
tensorflow (0.5.0)
vboxapi (1.0)
wheel (0.26.0)
using python -m pytest will work for you.
Or if you using virtual environment and installed pytest on virtualenv you should then run py.test alongside your virtual environment.
Check this website can be useful:http://pythontesting.net/framework/pytest/pytest-introduction/
I already had the latest version of pytest on macOS with Homebrew-installed Python 2.7 and this fixed it:
pip uninstall pytest
pip install pytest
Are you on a mac with homebrew by any chance?
I had the same issue and it basically came down to permissions/conflict with the mac os base installed python. pip install would not install or link stuff into /usr/local/bin (it happened with both virtualenv and pytest).
I uninstalled python 2.7 completely with homebrew (brew uninstall python).
Next, I reinstalled python with homebrew to fix pip (it was not a symlink in /usr/local/bin/pip where it should have been linked to Cellar) -- brew install python
Then I uninstalled pip with sudo -- sudo python -m pip uninstall pip to remove the pip owned by root
Now I uninstalled and reinstalled python with homebrew again to reinstall pip with the correct permissions brew uninstall python && brew install python
Next I fixed the python symlinks brew link python
Finally, pip install pytest worked! (and so did pip install virtualenv)
I found the information in the chosen answer from this post very helpful:
https://superuser.com/questions/915810/pip-not-working-on-hombrew-python-2-7-install.
If you're not on a mac, sorry for the noise...
I may be late, but while exploring this I noticed that this can be because the Scripts folder for python is not present in the PATH.
For me this is my scripts folder:
C:\Python38\Scripts\
If the path is a problem then running pip install pytest should actually you give you the warning with the path it was added to.
This should be present in the path. If on windows, edit the environment variables and this location to the PATH.
For me the path was incorrect because of an improper installation of python
I had the same issue. I had pytest v2.8.3 installed and the binary was on my path but under the name py.test. Upgrading to v3.0.3 added the regular pytest executable to the path.
I had the same problem. I have changed the Python installed folder permission to full access. And then uninstalled the pytest and installed again.
pip uninstall pytest
In my case, I had a similar issue in ubuntu 20.04. The below solution worked for me.
Cause: Shell remembers the previous version or previously used Path, hence we need to force the shell to 'forget' the old location - with -r
hash -r pytest
Then execute the tests it should work fine.
For MAC users:
Download python universal installer for mac:
https://www.python.org/ftp/python/3.10.5/python-3.10.5-macos11.pkg
Then try to install pytest module in terminal using this command:
pip install pytest
Hope this will fix the issue. Thanks!
use the command, pip install -U pytest and install it in your cmd prompt, it will solve the issueenter image description here
I used macbook air m2, and the way I deal with this problem is:
Command in terminal in macbook:
which pytest
/opt/anaconda3/bin/pytest -> my terminal shows this
Then you got the path of pytest, in the "Command", before "pytest", add its path and following with the path of python file you wanna test.
/opt/anaconda3/bin/pytest /Users/cindyng/Desktop/Testing.py
Done, and if you cannot find the path of python in macbook, "which python" also helps, and you can put it in "Home" and "Custom Python Builder".
Hope that helps, good luck!
I Fixed this issue via below steps.
1.First uninstall existing pytest.
2.Check python version.
3.then verify pytest version is supported with python version or not via github issue tracker.
4. via sudo install pytest
sudo pip install pytest
5. verify pytest version and insatlled correctly or not.
pip list
pytest --version
6.run any test using pytest test_abc.py
I encounter the same problem, python -m pytest works for me.

Windows reports error when trying to install package using pipenv

I installed pipenv by following the instructions here. From the Windows command prompt I ran
pip install --user pipenv
which returned the message
Successfully installed pipenv-5.3.3
Now I want to install the requests package using pipenv, so I ran
pipenv install requests
but this returned
'pipenv' is not recognized as an internal or external command,
operable program or batch file.
I have added the path
C:\Users\Robert\AppData\Roaming\Python\Python35\site-packages
to my Windows path environment variable, but I still receive the same error.
How can I install the requests package using pipenv?
EDIT: As I have remnants of Python 3.5 and Python 3.6 on my system, I'm going to uninstall everything and start anew. (I've just started learning Python and I want to keep this as simple as possible.)
I have a similar setup and faced a similar problem, but the solution I found was fairly simple. All of my PATH variables were already correct (from Python 3 the Windows Installer automatically does all of this).
The problem
The problem actually arises because of conflicting installations of virtualenv.
Fix
To address this problem you need to simply run the following commands:
First, remove your current version of virtualenv: pip uninstall virtualenv
Then, remove your current version of pipenv: pip uninstall pipenv
When you are asked Proceed (y/n)? just enter y. This will give you a clean slate.
Finally, you can once again install pipenv and its dependencies: pip install pipenv
This will also install the latest version of virtualenv.
Testing if it worked
Just enter pipenv --version in the command prompt and you should see the desired output.
Notes
I know this sounds the mundane, but it is actually the solution for Windows systems. You do not need to modify any of your system environment variables (please do not add site-packages to your environment variables).
python -m pipenv may work for you, (or python3 -m pipenv or py 3 -m pipenv) this is telling python to run the module pipenv instead of the terminal shortcut which sometimes doesn't install properly.
Just to show they are equivalent when I installed pipenv and run which pipenv it points to a file like /Library/Frameworks/Python.framework/Versions/3.6/bin/pipenv which looks like this:
#!/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
# -*- coding: utf-8 -*-
import re
import sys
from pipenv import cli
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(cli())
so it removes .pyw or .exe from the executable name then call pipenv.cli.cli(). It is likely there is a file like this on your machine it just didn't add python's /bin folder to your system PATH so it isn't accessible, there is usually a warning when installing python if this happens but no one checks those. :P
the module pipenv.__main__ which is run when using python -m pipenv looks like this:
from .cli import cli
if __name__ == '__main__':
cli()
Which calls pipenv.cli.cli(). So this main module absolutely does the same effective thing.
to solve this problem i need to start my CMD as administrator.
pip uninstall pipenv
pip install pipenv
To test this new configuration, you can write pipenv --version
Use python -m pipenv instead of just pipenv, it should work. Best of luck to you.
Try adding the following to Path environmental variable:
C:\Users\Robert\AppData\Roaming\Python\Python36\Scripts
instead of the \site-package, as that is where pipenv.exe is installed (at least for me).
use this cmd solve my problem :
python -m pipenv install django==2.1
Many thanks to #Srivats Shankar. In case you have tried what he said and it did not work, hope you did not forget to check your python path? If you have more than a single python version installed, doing pip uninstall virtualenv or pip uninstall pipenv might not help solve the problem.
Every python version is generally supposed to have its own pip installed. What you would do in this case is:
`-python -version_to_uninstall_virtualenv_from -m pip uninstall virtualenv; py --version -m pip uninstall virtualenv
-python -version_to_uninstall_pipenv_from -m pip uninstall pipenv; py --version -m pip uninstall pipenv`
Then you install pipenv with a similar command:
`-python -version_to_install_pipenv_on -m pip install pipenv; py --version -m pip uninstall pipenv`
I had an error like you sed and I just reinstalled pipenv and it fixed.
I used this command:
pip install pipenv
Instead of
C:\Users\Robert\AppData\Roaming\Python\Python35\site-packages
it should be
C:\Users\Robert\AppData\Roaming\Python\Python36\Scripts
after that, try closing and reopening the terminal
check warnings after installing pipenv. sometimes pipenv location not registered in environment variables.
I noticed several different situations with multiple python versions installed.
A preferred solution would be to use:
python -m pip install pipenv
This command for Python3.7 instance generates executables in
C:\Users\XXX\AppData\Local\Programs\Python\Python37\Scripts and it made setting up other packages easier.
Windows is not officially supported, I think.
ref: https://github.com/kennethreitz/pipenv/issues/70
Please check that pipenv is installed in your system by run following command in command promt:
pipenv --version
If it returns error, so please install again and set environment variable path in your system

How do I install a pip package globally instead of locally?

I am trying to install flake8 package using pip3 and it seems that it refuses to install because is already installed in one local location.
How can I force it to install globally (system level)?
pip3 install flake8
Requirement already satisfied (use --upgrade to upgrade): flake8 in ./.local/lib/python3.4/site-packages
Please note that I would prefer a generic solution (that should work on Debian, OS X maybe even Windows), one that should be used on any platform so I don't want to specify the destination myself.
For some weird reason it behaves like I already specified --user which in my case I didn't.
The only way I was able to install a package globally was to first remove it and install it again after this. Somehow it seems that pip (8.1.1) refuses to install a package globally if it exists locally.
Disclaimer: No virtual environments were used or harmed during the experiments.
Why don't you try sudo with the H flag? This should do the trick.
sudo -H pip install flake8
A regular sudo pip install flake8 will try to use your own home directory. The -H instructs it to use the system's home directory. More info at https://stackoverflow.com/a/43623102/
Maybe --force-reinstall would work, otherwise --ignore-installed should do the trick.
Where does pip installations happen in python?
I will give a windows solution which I was facing and took a while to solve.
First of all, in windows (I will be taking Windows as the OS here), if you do pip install <package_name>, it will be by default installed globally (if you have not activated a virtual enviroment).
Once you activate a virtual enviroment and you are inside it, all pip installations will be inside that virtual enviroment.
pip is installing the said packages but not I cannot use them?
For this pip might be giving you a warning that the pip executables like pip3.exe, pip.exe are not on your path variable.
For this you might add this path ( usually - C:\Users\<your_username>\AppData\Roaming\Programs\Python\ ) to your enviromental variables.
After this restart your cmd, and now try to use your installed python package. It should work now.
For windows 10:
Installing Python for all users is straight forward since when you install you have to click a checkbox for all users.
In order to install modules globally under C:\Program Files\Python310\Lib\site-packages
start CMD prompt as administrator and then install modules
python -m pip install selenium
For the Windows case:
Are you using virtualenv? If yes, deactivate the virtualenv. If you are not using a venv, the package should have already be installed on system level (system-wide). In that case, try to upgrade the package.
pip install flake8 --upgrade
I actually don‘t see your issue. Globally is any package which is in your python3 path‘s site package folder.
If you want to use it just locally then you must configure a virtualenv and reinstall the packages with an activated virtual environment.

virtualenv does not include pip

I am trying to create a virtual environment using virtualenv on Mac OS X El Capitan. I have installed Python 2.7.11 with brew, which includes pip, wheel and setuptools by default.
Hovewer, when I try to install virtualenv following instructions in the documentation or from any other resource, I get several problems:
virtualenv executable is not placed in /usr/local/bin after pip makes its job, so I need to ln -s it by hand (it may indicate, that there is something wrong with installation on this step).
After I run virtualenv venv, it creates new environment, catches Python 2.7.11 from brew-installation, but: there is no pip inside bin folder. That means, that if I try which pip, having venv activated, it returns a global position of pip — /usr/local/bin/pip, not /path/to/venv/bin/pip.
As a consequence, installing packages inside venv uses global pip and installs them to a global sites-packages, not that inside venv, and it's quite the opposite of what environment should do.
Could you please suggest what may be wrong and how to fix it?
EDIT: The thing to mention is that I used to have other versions of Python installed on my computer, which I have recently deleted as it is described in this answer. Maybe it causes the issue, and some more thorough cleaning is needed.
Try removing or renaming the .pydistutils.cfg file in your home directory, e.g. by renaming with mv ~/.pydistutils.cfg ~/oldpydistutils.cfg
I'm putting a detailed answer here to help others, but the original credit goes to this answer. If you know what specifically in .pydistutils.cfg was causing the problem, let me know!
I was having the same issue: my virtual environments were created without a local copy of pip, although they had a local copy of python. This meant that using $ pip from within the virtual environment installed to the global package location, and was not visible to the environment's python.
How I diagnosed this on my machine:
I create a virtualenvironment with $ virtualenv env
Activated the virtual environment with $ source env/bin/activate
Checked python location: run (env)$ which python with output /Users/<username>/env/bin/python (as expected)
Checked pip location: run (env)$ which pip with output /usr/local/bin/pip (NOT expected)
To check where our packages are going, we can try to install a package in the virtual environment:
Try to install a package: (env)$ pip install HTTPServer which succeeds
Try to run the package: (env)$ python -m HTTPServer which fails with error /Users/emunsing/env/bin/python: No module named HTTPServer
To double-check, try to install again: (env)$ pip install HTTPServer which produces Requirement already satisfied (use --upgrade to upgrade): HTTPServer in /usr/local/lib/python2.7/site-packages
Double-checking, we see that there's no Pip in the environment's /bin folder:
$ ls env/bin
activate activate.fish python python2
activate.csh activate_this.py python-config python2.7
And so while the system finds the local python version, it can't find a local pip to use and traverses the $PATH. It ended up using pip from /usr/local/bin, leaving me unable to install packages locally to the virtual environment.
Here's what I tried:
- Reinstalling python brew uninstall python followed by brew upgrade and brew install python --build-from-source
- Installing pip using the get-pip.py command as described in the Pip documentation
Here's what I ruled out:
- I was not using sudo pip ... which caused similar problems in this other question and haven't done so at any time on this Python/pip install
- My virtual environment didn't show a local installation of pip, as was the case in these similar questions: This one for Windows, This one for Mac OS X.
Ultimately, I found that eliminating the ~/.pydistutils.cfg file fixed the problem, allowing for fresh virtual environments that had their own local pip. The contents of my ~/.pydistutils.cfg file were:
[global]
verbose=1
[install]
install-scripts=$HOME/bin
[easy_install]
install-scripts=$HOME/bin
Simply renaming the ~/.pydistutils.cfg file appears to fix the problem: it seems that although this file was created by the homebrew installation, some settings in this file may be incompatible with virtualenv. While removing this file hasn't had any bad effects on my system, you may need to use the --user flag when installing packages with pip to the global environment (e.g. $ pip install --user HTTPServer). Here are more details on .pydistutils.cfg if you want to work on tailoring it for your needs.
virtualenv executable is not placed in /usr/local/bin after pip makes its job, so I need to ln -s it by hand (it may indicate, that there is something wrong with installation on this step).
Don't do that. That will only hide the bug and not solve the problem. Here's a short guide how to debug this kind of issues:
Start with which -a python. The first path you see should be /usr/local/bin/python, if not check your PATH variable.
Next, check which -a pip. Again the first path should be /usr/local/bin/pip. If not, run python -m ensurepip and recheck.
Now install virtualenv using pip install virtualenv, after that check the output of which -a virtualenv. The first path should be /usr/local/bin/virtualenv, if not check the output of env |grep PYTHON for unexpected environment variables.
Finally check the output of virtualenv --version to make sure you have the latest version.
I had the issue when running virtualenv: "ImportError: No module named pip."
My solution was to downgrade virtualenv. I had 16.2.0.
pip uninstall virtualenv
pip install virtualenv==15.1.0
Just hit same issue on Linux. Seems like there are multiple causes of this issue, but for me answer was to remove ~/.pip/.
Details: I had this in my .pip/pip.conf for some reason I can't remember:
$ cat ~/.pip/pip.conf
[global]
use_https = True
index = https://pypi.python.org/pypi
prefix = /home/sam/local/
and was using local versions on Python, Pip installed at ~/local/. For some reason virtualenv installed pip must pick up prefix = /home/sam/local/ setting and pip was being installed there.
Try this: sudo apt install pythonV.v-distutils.
In my case V.v == 3.8.
This worked for me.

In a virtualenv, pip can see all of my site-packages when I use list, is this normal?

I thought that virtualenv was supposed to encapsulate and hide all of your packages that were already installed. But when I type
$sudo virtualenv -p /usr/bin/python3 testenv
$source ~/testenv/bin/activate
$sudo pip list
I get:
apt-xapian-index (0.45)
argparse (1.2.1)
chardet (2.0.1)
cmsplugin-filer (0.10)
colorama (0.2.5)
command-not-found (0.3)
debtagshw (0.1)
defer (1.0.6)
dirspec (13.10)
...and many more
Even with the --local parameter. Is virtualenv broken?
Also when I type: $ which pip I still get: /home/jelikraftuser/testenv/bin/pip Which seems correct.
Reading the answers in this post: pip installing in global site-packages instead of virtualenv
I found the suggestion to run pip directly with $sudo ~/testenv/bin/pip list and it actually worked, it only listed 2 packages. However when I run which pip it lists the pip in the virtualenv as being the one which would be run.
So I'm sort of lost at this point. Calling the pip list with the full path gives me the correct (small) list of two packages, and calling pip list without the full path gives me a giant list of packages, which is incorrect. So, where do I go from here?
How can I make it not recognise globally installed packages as being installed in the virtualenv when I run pip without the full path?
OKAY UPDATE! This is kinda interesting:
(testenv)$ pip --version
pip 1.5.6 from /home/jelikraftuser/testenv/lib/python3.4/site-packages (python 3.4)
(testenv)$ sudo pip --version
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
When I run pip as sudo it runs one, and when i run it as non-sudo it runs a different pip. Why would it do that? And if I'm going to be installing a package, i'll be running it as sudo, so I need sudo to use the correct pip.
Second update:
Reading this stackoverflow:sudo changes PATH - why?
I found that on ubuntu you cannot change the path variable for sudo, but this still confuses me since it was working before... So I'm still confused. Insight anyone? Previously I could type sudo pip list in a virtualenv and get a near-empty list. Does it do the same for you?
EDIT 3: What else it does:
When I run sudo pip install --download-cache=~/.pip-cache -r piprequirements.txt
it says that everything is already installed but when I enter python I cannot import them, but when I run python as sudo I can import them. So superuser can see packages that are globally installed > but I need to use sudo to install packages > so I can't install packages that are already globally installed. Also when I try to run pip3 as sudo, it says sudo: pip3: command not found. So this is definately an issue with ubuntu and how the environment path changes when you run sudo. Is not everyone else running into this issue then? I'm sure lots of people are using ubuntu, no?

Categories