Reputation: 121
I am running a django project with a virtualenv that was working completely fine up until this afternoon. I went to run source my-env/bin/activate
and it seemed to activate (it gave me the usual command prompt), but when I tried python manage.py runserver
it said it could not locate django. I ran a python script and tried to import django and sure enough it said there was no module named django. So I removed this virtualenv and created a new one and did a pip install -r requirements.txt
. It was then I noticed that pip was hanging forever and upon type ^C
it would give a long traceback which I provided below. Once this happened I tried once again to delete the virtualenv and start over only now when I typed virtualenv new-env
it would hang on "Installing setuptools, pip, wheel..." and also gave a long traceback upon entering ^C
. I have looked all over the online forums and tried everything to fix this and nothing seems to be working. If anyone has any ideas on how to fix this I would really appreciate it.
Installing setuptools, pip, wheel...^CTraceback (most recent call last):
File "/usr/local/bin/virtualenv", line 11, in <module>
done.
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 669, in main
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 2327, in <module>
raise SystemExit(popen.wait())
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1384, in wait
main()
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 711, in main
symlink=options.symlink)
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 944, in create_environment
download=download,
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 900, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 767, in call_subprocess
line = stdout.readline()
KeyboardInterrupt
pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 476, in _eintr_retry_call
return func(*args)
KeyboardInterrupt
Upvotes: 9
Views: 9560
Reputation: 13289
I was having a lot of trouble with this and nothing I tried from various StackOverflow discussions was helping. I had made absolutely certain it was not a networking issue, and in fact I was hoping that upgrading from Ubuntu 16 to 18 would magically fix it... but it didn't. So I figured I had to actually fix it.
I was beginning to suspect it had something to do with my user directory because it worked when I tried it as the root user. Furthermore, I had copied my entire home directory to a temporary disk and then back to the main hard drive after the uprade (because I wanted a fresh install of Ubuntu 18's "minimal" option). So I was beginning to suspect that something in my home folder was culpable.
Running virtualenv
with the -vv
option only showed that it was stopping on: Collecting setuptools
.
Considering that many were recommending checking the internet connection, I figured it might be something related to cache. So I tried emptying the ~/.cache
directory with:
rm -rf ~/.cache/*
Immediately the virtualenv
command that was hanging in another terminal window continued and finished within some seconds.
I don't know if emptying the cache in this manner with a bunch of applications running is considered brave, but anyway, it did the trick.
@t354 suggests only removing ~/.cache/pip
with:
rm -rf ~/.cache/pip
Haven't tried it myself, but if it works as well, then it's probably safer than deleting everything inside ~/.cache
Upvotes: 5
Reputation: 697
Dude I solved this issue after a long period of pain.
Reinstalling the following packages pip \ setuptools \ wheels with a couple of option.
python -m pip install <package_name> --upgrade --force-reinstall --no-binary <package_name>
Probably the issue was due to a not backward compatibility of a version of one of the package above.
Upvotes: 0
Reputation: 321
Probably not very helpful, but I experienced the same symptoms and found using the verbose option to be helpful:
mkvirtualenv new-env -v
The output pointed at a proxy issue I had, preventing usage of setuptools, which I resolved by fixing my proxy settings:
Installing setuptools, pip, wheel...
Collecting setuptools
Retrying (Retry(total=4, connect=None, read=None, redirect=None))
after connection broken by 'ProxyError('Cannot connect to proxy.',
timeout('timed out',))': /devpi/setuptools/
Upvotes: 7