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

Invalid pip installation after creating virtualenv #1719

Closed
tzulberti opened this issue Mar 12, 2020 · 3 comments · Fixed by #1728
Closed

Invalid pip installation after creating virtualenv #1719

tzulberti opened this issue Mar 12, 2020 · 3 comments · Fixed by #1728
Labels

Comments

@tzulberti
Copy link

Issue

I created a Python 2.7 virtualenv, and when I try to use pip inside the virtualenv I got an error:

$ virtualenv --python python2.7 /tmp/bar
created virtual environment CPython2.7.16.final.0-64 in 257ms
  creator CPython2Posix(dest=/tmp/bar, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/tmp/tmpl2wpmzv9/seed-app-data/v1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator
$ source /tmp/bar/bin/activate
(bar) $ pip
pip      pip2     pip-2.7  pip-3.6  
(bar) $ pip
Traceback (most recent call last):
  File "/tmp/bar/bin/pip", line 5, in <module>
    from pip._internal.cli.main import main
ImportError: No module named _internal.cli.main

If I run pip-2.7 outside the virtulenv, everything seems to be working fine:

$ pip-2.7 --version
pip 9.0.3 from /usr/lib/python2.7/dist-packages (python 2.7)

Environment

Provide at least:

  • OS:

  • pip list of the host python where virtualenv is installed:

$ virtualenv --version
virtualenv 20.0.10 from /usr/local/lib/python3.6/site-packages/virtualenv/init.py


**Output of the virtual environment creation**

Make sure to run the creation with `-vvv --with-traceback`:

```console
$ virtualenv -vvv --with-traceback --python python2.7 /tmp/bar2

52 could not create app data folder /home/foobar/.local/share/virtualenv due to FileNotFoundError(2, 'No such file or directory') [INFO app_data:54]
62 created temporary app data folder /tmp/tmpiielo21j [DEBUG app_data:32]
62 find interpreter for spec PythonSpec(implementation=CPython, major=2, minor=7) [INFO builtin:44]
63 proposed PythonInfo(spec=CPython3.6.10.final.0-64, exe=/usr/bin/python3.6, platform=linux, version='3.6.10 (default, Feb 10 2020, 19:55:14) \n[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]', encoding_fs_io=utf-8-UTF-8) [INFO builtin:50]
63 discover PATH[0]=/usr/local/bin [DEBUG builtin:77]
63 filesystem is case-sensitive [DEBUG info:28]
63 discover PATH[1]=/bin [DEBUG builtin:77]
63 discover PATH[2]=/usr/bin [DEBUG builtin:77]
63 Attempting to acquire lock 140256138179752 on /tmp/tmpiielo21j/py_info/20.0.10/beb4f305451b4835b36a63cb1c75e625a7251cf8d76b65be2f5856eee68cb551.lock [DEBUG filelock:270]
64 Lock 140256138179752 acquired on /tmp/tmpiielo21j/py_info/20.0.10/beb4f305451b4835b36a63cb1c75e625a7251cf8d76b65be2f5856eee68cb551.lock [INFO filelock:274]
64 get interpreter info via cmd: /usr/bin/python2.7 /usr/local/lib/python3.6/site-packages/virtualenv/discovery/py_info.py [DEBUG cached_py_info:105]
91 write PythonInfo to /tmp/tmpiielo21j/py_info/20.0.10/beb4f305451b4835b36a63cb1c75e625a7251cf8d76b65be2f5856eee68cb551.json for /usr/bin/python2.7 [DEBUG cached_py_info:91]
92 Attempting to release lock 140256138179752 on /tmp/tmpiielo21j/py_info/20.0.10/beb4f305451b4835b36a63cb1c75e625a7251cf8d76b65be2f5856eee68cb551.lock [DEBUG filelock:315]
92 Lock 140256138179752 released on /tmp/tmpiielo21j/py_info/20.0.10/beb4f305451b4835b36a63cb1c75e625a7251cf8d76b65be2f5856eee68cb551.lock [INFO filelock:318]
92 proposed PathPythonInfo(spec=CPython2.7.16.final.0-64, exe=/usr/bin/python2.7, platform=linux2, version='2.7.16 (default, Jul 19 2019, 22:59:28) \n[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]', encoding_fs_io=UTF-8-None) [INFO builtin:50]
92 accepted PathPythonInfo(spec=CPython2.7.16.final.0-64, exe=/usr/bin/python2.7, platform=linux2, version='2.7.16 (default, Jul 19 2019, 22:59:28) \n[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]', encoding_fs_io=UTF-8-None) [DEBUG builtin:52]
141 create virtual environment via CPython2Posix(dest=/tmp/bar2, clear=False, global=False) [INFO session:52]
142 no include folders as can't find include marker /usr/local/include/python2.7/Python.h [DEBUG cpython2:49]
142 create folder /tmp/bar2/bin [DEBUG _sync:21]
142 create folder /tmp/bar2/lib/python2.7/dist-packages [DEBUG _sync:21]
142 create folder /tmp/bar2/lib64/python2.7/dist-packages [DEBUG _sync:21]
142 write /tmp/bar2/pyvenv.cfg [DEBUG pyenv_cfg:34]
142 	home = /usr [DEBUG pyenv_cfg:38]
142 	implementation = CPython [DEBUG pyenv_cfg:38]
142 	version_info = 2.7.16.final.0 [DEBUG pyenv_cfg:38]
142 	virtualenv = 20.0.10 [DEBUG pyenv_cfg:38]
142 	include-system-site-packages = false [DEBUG pyenv_cfg:38]
142 	base-prefix = /usr [DEBUG pyenv_cfg:38]
142 	base-exec-prefix = /usr [DEBUG pyenv_cfg:38]
142 	base-executable = /usr/bin/python2.7 [DEBUG pyenv_cfg:38]
143 copy /usr/bin/python2.7 to /tmp/bar2/bin/python [DEBUG _sync:48]
143 symlink /usr/lib64/python2.7/os.py to /tmp/bar2/lib/python2.7/os.py [DEBUG _sync:40]
143 symlink /usr/lib64/python2.7/os.pyc to /tmp/bar2/lib/python2.7/os.pyc [DEBUG _sync:40]
143 symlink directory /usr/lib64/python2.7/lib-dynload to /tmp/bar2/lib/python2.7/lib-dynload [DEBUG _sync:40]
143 create /tmp/bar2/lib/python2.7/dist-packages/_virtualenv.py [DEBUG api:60]
143 create virtualenv import hook file /tmp/bar2/lib/python2.7/dist-packages/_virtualenv.pth [DEBUG api:63]
144 ============================== target debug ============================== [DEBUG session:54]
144 debug via /tmp/bar2/bin/python /usr/local/lib/python3.6/site-packages/virtualenv/create/debug.py [DEBUG creator:182]
144 {
"sys": {
  "executable": "/tmp/bar2/bin/python",
  "_base_executable": null,
  "prefix": "/usr",
  "base_prefix": null,
  "real_prefix": null,
  "exec_prefix": "/usr",
  "base_exec_prefix": null,
  "path": [
    "/usr/lib/python27.zip",
    "/usr/lib64/python2.7",
    "/usr/lib64/python2.7/plat-linux2",
    "/usr/lib64/python2.7/lib-tk",
    "/usr/lib64/python2.7/lib-old",
    "/usr/lib64/python2.7/lib-dynload",
    "/usr/local/lib64/python2.7/site-packages",
    "/usr/local/lib/python2.7/site-packages",
    "/usr/local/lib/python2.7/site-packages/StreamPublisher-1.3.2-py2.7.egg",
    "/usr/lib64/python2.7/site-packages",
    "/usr/lib/python2.7/site-packages",
    "/usr/lib64/python2.7/dist-packages",
    "/usr/lib64/python2.7/dist-packages/PIL",
    "/usr/lib/python2.7/dist-packages"
  ],
  "meta_path": [],
  "fs_encoding": "UTF-8",
  "io_encoding": null
},
"version": "2.7.16 (default, Jul 19 2019, 22:59:28) \n[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]",
"os": "<module 'os' from '/usr/lib64/python2.7/os.pyc'>",
"site": "<module 'site' from '/usr/lib64/python2.7/site.pyc'>",
"datetime": "<module 'datetime' from '/usr/lib64/python2.7/lib-dynload/datetime.so'>",
"math": "<module 'math' from '/usr/lib64/python2.7/lib-dynload/math.so'>",
"json": "<module 'json' from '/usr/lib64/python2.7/json/__init__.pyc'>"
} [DEBUG session:55]
158 add seed packages via FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/tmp/tmpiielo21j/seed-app-data/v1) [INFO session:59]
158 Attempting to acquire lock 140256123427976 on /tmp/tmpiielo21j/seed-app-data/v1/2.7/wheels.lock [DEBUG filelock:270]
158 Lock 140256123427976 acquired on /tmp/tmpiielo21j/seed-app-data/v1/2.7/wheels.lock [INFO filelock:274]
159 get bundled wheel /usr/local/lib/python3.6/site-packages/virtualenv/seed/embed/wheels/pip-20.0.2-py2.py3-none-any.whl [DEBUG acquire:51]
159 get bundled wheel /usr/local/lib/python3.6/site-packages/virtualenv/seed/embed/wheels/wheel-0.34.2-py2.py3-none-any.whl [DEBUG acquire:51]
159 get bundled wheel /usr/local/lib/python3.6/site-packages/virtualenv/seed/embed/wheels/setuptools-44.0.0-py2.py3-none-any.whl [DEBUG acquire:51]
162 install wheel from wheel /tmp/tmpiielo21j/seed-app-data/v1/2.7/wheels/wheel-0.34.2-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:46]
162 install setuptools from wheel /tmp/tmpiielo21j/seed-app-data/v1/2.7/wheels/setuptools-44.0.0-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:46]
162 install pip from wheel /tmp/tmpiielo21j/seed-app-data/v1/2.7/wheels/pip-20.0.2-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:46]
162 build install image to /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/wheel-0.34.2-py2.py3-none-any of wheel-0.34.2-py2.py3-none-any.whl [DEBUG base:57]
162 build install image to /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/setuptools-44.0.0-py2.py3-none-any of setuptools-44.0.0-py2.py3-none-any.whl [DEBUG base:57]
162 build install image to /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/pip-20.0.2-py2.py3-none-any of pip-20.0.2-py2.py3-none-any.whl [DEBUG base:57]
176 changing mode of /tmp/tmpp8jbavqh/wheel-2.7 to 775 [INFO util:566]
177 changing mode of /tmp/tmpp8jbavqh/wheel to 775 [INFO util:566]
177 changing mode of /tmp/tmpp8jbavqh/wheel2 to 775 [INFO util:566]
180 copy directory /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/wheel-0.34.2-py2.py3-none-any/wheel-0.34.2.dist-info to /tmp/bar2/lib/python2.7/dist-packages/wheel-0.34.2.dist-info [DEBUG _sync:48]
185 copy /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/wheel-0.34.2-py2.py3-none-any/wheel-0.34.2.virtualenv to /tmp/bar2/lib/python2.7/dist-packages/wheel-0.34.2.virtualenv [DEBUG _sync:48]
186 copy directory /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/wheel-0.34.2-py2.py3-none-any/wheel to /tmp/bar2/lib/python2.7/dist-packages/wheel [DEBUG _sync:48]
193 changing mode of /tmp/bar2/bin/wheel-2.7 to 775 [INFO util:566]
194 changing mode of /tmp/bar2/bin/wheel to 775 [INFO util:566]
194 changing mode of /tmp/bar2/bin/wheel2 to 775 [INFO util:566]
194 generated console scripts wheel2 wheel wheel-2.7 [DEBUG base:53]
217 changing mode of /tmp/tmpn21zo58q/easy_install-2.7 to 775 [INFO util:566]
217 changing mode of /tmp/tmpn21zo58q/easy_install2 to 775 [INFO util:566]
218 changing mode of /tmp/tmpn21zo58q/easy_install to 775 [INFO util:566]
222 copy directory /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/setuptools-44.0.0-py2.py3-none-any/setuptools to /tmp/bar2/lib/python2.7/dist-packages/setuptools [DEBUG _sync:48]
238 copy /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/setuptools-44.0.0-py2.py3-none-any/setuptools-44.0.0.virtualenv to /tmp/bar2/lib/python2.7/dist-packages/setuptools-44.0.0.virtualenv [DEBUG _sync:48]
238 copy directory /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/setuptools-44.0.0-py2.py3-none-any/setuptools-44.0.0.dist-info to /tmp/bar2/lib/python2.7/dist-packages/setuptools-44.0.0.dist-info [DEBUG _sync:48]
240 copy /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/setuptools-44.0.0-py2.py3-none-any/easy_install.py to /tmp/bar2/lib/python2.7/dist-packages/easy_install.py [DEBUG _sync:48]
240 copy directory /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/setuptools-44.0.0-py2.py3-none-any/pkg_resources to /tmp/bar2/lib/python2.7/dist-packages/pkg_resources [DEBUG _sync:48]
243 changing mode of /tmp/bar2/bin/easy_install-2.7 to 775 [INFO util:566]
243 changing mode of /tmp/bar2/bin/easy_install2 to 775 [INFO util:566]
243 changing mode of /tmp/bar2/bin/easy_install to 775 [INFO util:566]
243 generated console scripts easy_install easy_install2 easy_install-2.7 [DEBUG base:53]
266 changing mode of /tmp/tmpmqz44x17/pip-2.7 to 775 [INFO util:566]
266 changing mode of /tmp/tmpmqz44x17/pip2 to 775 [INFO util:566]
266 changing mode of /tmp/tmpmqz44x17/pip to 775 [INFO util:566]
278 copy directory /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/pip-20.0.2-py2.py3-none-any/pip-20.0.2.dist-info to /tmp/bar2/lib/python2.7/dist-packages/pip-20.0.2.dist-info [DEBUG _sync:48]
279 copy directory /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/pip-20.0.2-py2.py3-none-any/pip to /tmp/bar2/lib/python2.7/dist-packages/pip [DEBUG _sync:48]
303 copy /tmp/tmpiielo21j/seed-app-data/v1/2.7/image/CopyPipInstall/pip-20.0.2-py2.py3-none-any/pip-20.0.2.virtualenv to /tmp/bar2/lib/python2.7/dist-packages/pip-20.0.2.virtualenv [DEBUG _sync:48]
304 changing mode of /tmp/bar2/bin/pip-2.7 to 775 [INFO util:566]
304 changing mode of /tmp/bar2/bin/pip2 to 775 [INFO util:566]
304 changing mode of /tmp/bar2/bin/pip to 775 [INFO util:566]
304 generated console scripts pip2 pip pip-2.7 [DEBUG base:53]
304 Attempting to release lock 140256123427976 on /tmp/tmpiielo21j/seed-app-data/v1/2.7/wheels.lock [DEBUG filelock:315]
304 Lock 140256123427976 released on /tmp/tmpiielo21j/seed-app-data/v1/2.7/wheels.lock [INFO filelock:318]
304 add activators for Bash, CShell, Fish, PowerShell, Python [INFO session:65]
305 write /tmp/bar2/pyvenv.cfg [DEBUG pyenv_cfg:34]
305 	home = /usr [DEBUG pyenv_cfg:38]
305 	implementation = CPython [DEBUG pyenv_cfg:38]
305 	version_info = 2.7.16.final.0 [DEBUG pyenv_cfg:38]
305 	virtualenv = 20.0.10 [DEBUG pyenv_cfg:38]
305 	include-system-site-packages = false [DEBUG pyenv_cfg:38]
306 	base-prefix = /usr [DEBUG pyenv_cfg:38]
306 	base-exec-prefix = /usr [DEBUG pyenv_cfg:38]
306 	base-executable = /usr/bin/python2.7 [DEBUG pyenv_cfg:38]
306 remove temporary app data folder /tmp/tmpiielo21j [DEBUG app_data:35]
314 created virtual environment CPython2.7.16.final.0-64 in 263ms
creator CPython2Posix(dest=/tmp/bar2, clear=False, global=False)
seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/tmp/tmpiielo21j/seed-app-data/v1)
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator [WARNING __main__:21]
@tzulberti tzulberti added the bug label Mar 12, 2020
@gaborbernat
Copy link
Contributor

Can you provide any reproducible of this, seems to work on macOs. What platform, etc? (ideally, a Docker build if possible)

@tzulberti
Copy link
Author

This is the minimal Dockerfile I was able to create to reproduce the error:

FROM amazonlinux:1

RUN yum -y install python27 python27-devel python36 python36-devel python27-pip

RUN pip-3.6 install --upgrade virtualenv

RUN virtualenv --python python2.7 /tmp/bar

RUN source /tmp/bar/bin/activate && pip freeze

@gaborbernat
Copy link
Contributor

Hello, a fix for this issue has been released via virtualenv 20.0.11; see https://pypi.org/project/virtualenv/20.0.11/ (https://virtualenv.pypa.io/en/latest/changelog.html#v20-0-11-2020-03-18). Please give a try and report back if your issue has not been addressed; if not, please comment here, and we'll reopen the ticket. We want to apologize for the inconvenience this has caused you and say thanks for having patience while we resolve the unexpected bugs with this new major release.
thanks

@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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants