Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--system-site-packages fails if PIP_REQUIRE_VIRTUALENV=true #557

Closed
carolyn-idi opened this issue Jan 28, 2014 · 5 comments
Closed

--system-site-packages fails if PIP_REQUIRE_VIRTUALENV=true #557

carolyn-idi opened this issue Jan 28, 2014 · 5 comments

Comments

@carolyn-idi
Copy link

Based on some online docs I set up pip so it only runs for an activated virtual environment by setting PIP_REQUIRE_VIRTUALENV to true.

I have some packages installed on the system level that I'd like to install by default for some of my projects. My understanding is that I need to use the --system-site-packages flag to get this to happen.

If PIP_REQUIRE_VIRUTALENV is set to false - everything works ok.
If it's set to true it fails with the following errors:

Running virtualenv with interpreter /usr/local/bin/python2.7
New python executable in .venv/bin/python
Installing setuptools, pip...
  Complete output from command /Users/insomniac/Repo/site/.venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
  Could not find an activated virtualenv (required).
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.py", line 2338, in <module>
    main()
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.py", line 824, in main
    symlink=options.symlink)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.py", line 992, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.py", line 960, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.py", line 902, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/insomniac/Repo/site/.venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 3
Activating virtualenv "site"...
-bash: .venv/bin/activate: No such file or directory

I'm not sure if this is a bug or if there is another way that this should be done.

@pfmoore
Copy link
Member

pfmoore commented Jan 28, 2014

Sounds like a bug. Virtualenv runs pip, using the new virtualenv's python, but it doesn't activate the virtuialenv. Maybe we need to unset PEP_REQUIRE_VIRTUALENV when doing so.

I can't think of an obvious workaround apart from unsetting that variable temporarily when creating virtualenvs.

Maybe pip needs an --isolated mode to ignore user config files and environment variables (and virtualenv could then use that).

@Ivoz
Copy link

Ivoz commented Jan 28, 2014

As alternatives,

A) you can provide -i mypackage (many times) to the mkvirtualenv command to automatically install packages after creating it;

B) virtualenvwrapper has a great deal of functionality for handling this sort of functionality. From a postmkvirtualenv file to issue commands, to project templates

Hope you might find those useful as well.

@carolyn-idi
Copy link
Author

I really like the idea of temporarily turning PIP_REQUIRE_VIRTUALENV off for the process and then turn it back on (if it was on in the first place). That seems the easiest and it's what I can do manually for now. I'm not using virtualenvwrapper at the moment (although I will look into it).

@dstufft dstufft mentioned this issue Jan 5, 2015
5 tasks
@piotr-dobrogost
Copy link

piotr-dobrogost commented Jan 16, 2017

Maybe pip needs an --isolated mode to ignore user config files and environment variables (and virtualenv could then use that).

Pip does have --isolated flag for some time now. Setting PIP_REQUIRE_VIRTUALENV=1 and running virtualenv issue557 does not error with virtualenv 15.0.1. Probably this was fixed then.

@stale
Copy link

stale bot commented Jan 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Just add a comment if you want to keep it open. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 14, 2019
@stale stale bot closed this as completed Jan 21, 2019
@pypa pypa locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants