I am trying to follow this tutorial to get a django application up on pythonanywhere, but when trying to create a virtual environment using
virtualenv --python=python3.5 myvenv
The console hangs
I have done this before a while ago and I remember it was all quite painless but when running this command the console is just hanging and I eventually get put in the tarpit. When I interrupt the process I get some errors around Python 2.7
virtualenv --python=python3.5 myvenv
Running virtualenv with interpreter /usr/bin/python3.5
Using base prefix '/usr'
New python executable in /home/username/myvenv/bin/python3.5
Also creating executable in /home/username/myvenv/bin/python
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 669, in main
Traceback (most recent call last):
raise SystemExit(popen.wait())
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 2327, in <module>
File "/usr/lib/python2.7/subprocess.py", line 1376, in wait
pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
File "/usr/lib/python2.7/subprocess.py", line 476, in _eintr_retry_call
return func(*args)
KeyboardInterrupt
main()
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 711, in main
symlink=options.symlink)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 944, in create_environment
download=download,
File "/usr/local/lib/python2.7/dist-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/dist-packages/virtualenv.py", line 767, in call_subprocess
line = stdout.readline()
KeyboardInterrupt
Not sure if these relate to anything or if they are just because the interrupt.
General practice is to reference the python binary directly, run virtualenv as a module, and specify the directory in which to place the virtualenv. For your example above:
/path/to/python/bin/python3.5 -m virtualenv myvenv
This will create the virtual environment in myvenv, running python3.5. Note: your base install of python3.5 must have virtualenv library installed (either through pip or source).
Hope this helps! :)
Related
I try to recreate the virtualenv:
foo_bar_d#aptguettler:~$ virtualenv --system-site-packages .
I get this exception:
foo_bar_d#aptguettler:~$ virtualenv --system-site-packages .
New python executable in /home/foo_bar_d/bin/python
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 711, in main
symlink=options.symlink)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 924, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 1230, in install_python
shutil.copyfile(executable, py_executable)
File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 26] Text file busy: '/home/foo_bar_d/bin/python'
Does someone know why this exception happens?
I had the exact same problem :)
virtualenv works (afaik) by modifying a copy of the python executable in the virtualenv directory area.
You must have a process using the virtualenv already so the copy of the python executable is 'in use' (technically it's mmap()'ed into memory whilst it's executing).
Unless you need to change the setup of a virtualenv you don't need to re-run the virtualenv command every time - once it's setup you just activate it when needed.
As to why it happens - It's possible that you have a service running at boot time:
ps -ef | grep python
Kill Python Processes running on your system with pkill python
I will work
I'm running Python 2.7.9 on Yosemite (10.10.2), and my pip installation has gone wrong.
I can no longer install pip using get-pip.py:
sth:~ $ sudo python get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 20204, in <module>
main()
File "get-pip.py", line 152, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 130, in bootstrap
sys.exit(pip.main(["install", "--upgrade"] + packages + args))
File "/tmp/tmpdUeSSr/pip.zip/pip/__init__.py", line 217, in main
File "/tmp/tmpdUeSSr/pip.zip/pip/basecommand.py", line 183, in main
File "/tmp/tmpdUeSSr/pip.zip/pip/compat/dictconfig.py", line 565, in dictConfig
File "/tmp/tmpdUeSSr/pip.zip/pip/compat/dictconfig.py", line 332, in configure
AttributeError: 'module' object has no attribute '_handlerList'
I can use easy_install, and then create a symlink to it in /usr/local/bin, but trying to install using it gives me the same error, subsequently:
sth:~ $ sudo pip install twine
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==6.0.8', 'console_scripts', 'pip')()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/__init__.py", line 217, in main
return command.main(cmd_args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/basecommand.py", line 183, in main
for name in ["pip._vendor", "distlib", "requests", "urllib3"]
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/compat/dictconfig.py", line 565, in dictConfig
dictConfigClass(config).configure()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/compat/dictconfig.py", line 332, in configure
del logging._handlerList[:]
AttributeError: 'module' object has no attribute '_handlerList'
I'm certain it's not a problem with pip, so wondering what I've done wrong…
Sorry for necroing but for the sake of other googlers:
As pointed out here, you should not install logging with pip as it messes up the system version. I am not sure when this changed though.
So removing yourpythoninstallpath/lib/python2.7/site-packages/logging should remove the error.
I'd gotten a similar error an hour ago and found this question.
However I've solved it just now.
Although you might not think it useful, I hope this answer helps you solving the problem.
In fact, when I use virtualenvwrapper, I want to control an ENV suddenly.
So I created a backup directory for the reason in the same directory where another ENV is.
After that, There were not only 2 ENVs but also 3 directories related to ENV in .virtualenv.
It made some path to site-packages and etc change helter-skelter apparently.
That is why, if you don't confirm the files about Virtualenv, I reccomend you to do.
The error with me is the following.
~ pip freeze
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==6.0.6', 'console_scripts', 'pip')()
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg/pip/__init__.py", line 217, in main
return command.main(cmd_args)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg/pip/basecommand.py", line 183, in main
for name in ["pip._vendor", "distlib", "requests", "urllib3"]
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg/pip/compat/dictconfig.py", line 565, in dictConfig
dictConfigClass(config).configure()
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg/pip/compat/dictconfig.py", line 332, in configure
del logging._handlerList[:]
AttributeError: 'module' object has no attribute '_handlerList'
i'm running Python 2.7 with my debian testing and i've a probleme using virtualenv.
Im trying to create a virtualenv on a partition which is mount like
/dev/sda5 /media/misc vfat users,defaults,uid=1000,gid=1000,exec,umask=0 0 0
So, rights seems ok but virtualenv returns me :
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 3, in <module>
virtualenv.main()
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 938, in main
never_download=options.never_download)
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1039, in create_environment
site_packages=site_packages, clear=clear))
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1186, in install_python
copyfile(join(stdlib_dir, fn), join(lib_dir, fn))
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 430, in copyfile
copyfileordir(src, dest)
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 405, in copyfileordir
shutil.copytree(src, dest, True)
File "/usr/lib/python2.7/shutil.py", line 206, in copytree
raise Error, errors
shutil.Error: [('/usr/lib/python2.7/config/libpython2.7.so', 'seb/lib/python2.7/config /libpython2.7.so', '[Errno 1] Operation not permitted')]
i've installed virtualenv with apt.
using virtualenv in my /home is successfull
can you help me ?
fixed. I don't exactly why, but i've formated my partiton with a ntfs type resolves the issue.
It seems that fat32 system adds control over fstab
EDIT2: OK this is weird. (I can't answer my own question, so I just put it as another edit to the question. I think it has something to do with the fact that I tried to do this installation within a Dropbox-synced directory. I got this to work on my Desktop. Can anyone explain why this is the case?
Original question:
I'm trying to do Heroku's Python setup tutorial (http://devcenter.heroku.com/articles/python), on my Mac OS X (Lion), but I get caught up with the step of creating a virtualenv.
So what I did was this in the command line (not using sudo caused permissions error):
sudo pip install virtualenv
But then, when I do "virtualenv venv --distribute" (I also tried with sudo), I get the following error:
New python executable in venv/bin/python
Installing distribute..............................................................................................................................................................................................................................................................................................done.
Installing pip...
Error [Errno 2] No such file or directory while executing command /Users/AndyFang/Drop...env/bin/easy_install /Library/Python/2.7/...pport/pip-1.1.tar.gz
...Installing pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.7.1.2', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv.py", line 928, in main
never_download=options.never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1042, in create_environment
install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 640, in install_pip
filter_stdout=_filter_setup)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 966, in call_subprocess
cwd=cwd, env=env)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 672, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1202, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Not really sure what to do. It seemed like I didn't have easy_install on my Mac, but I do have it... I'm not sure what the deal is?
EDIT: I also just tried installing virtualenv with easy_install, but I get the exact same error.
If your problem is the same as mine, then it's because there's a space somewhere in the path to your Dropbox-synced folder.
Virtualenvs aren't portable, so you can't keep them synced across multiple machines if the paths don't match up.
In general, it's a bad idea :)
I've been trying to get TurboGears installed on Windows by following this site.
I've installed virtualenv but when I execute the command "virtualenv --no-site-packages testproj", I get the following message:
New python executable in testproj\Scripts\python.exe
Traceback (most recent call last):
File "C:\Python26\Scripts\virtualenv-script.py", line 8, in
load_entry_point('virtualenv==1.4.5', 'console_scripts', 'virtualenv')()
File "C:\Python26\lib\site-packages\virtualenv-1.4.5-py2.6.egg\virtualenv.py", line 529, in main
use_distribute=options.use_distribute)
File "C:\Python26\lib\site-packages\virtualenv-1.4.5-py2.6.egg\virtualenv.py", line 612, in create_environment
site_packages=site_packages, clear=clear))
File "C:\Python26\lib\site-packages\virtualenv-1.4.5-py2.6.egg\virtualenv.py", line 837, in install_python
stdout=subprocess.PIPE)
File "C:\Python26\lib\subprocess.py", line 621, in __init__
errread, errwrite)
File "C:\Python26\lib\subprocess.py", line 830, in _execute_child
startupinfo)
WindowsError: [Error 14001] This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem
Can someone help me debug this ? If any one knows a better tutorial to install turbogears, please let me know.
I figured out the error. Apparently, virtualenv does not like it if folder names have spaces (eg Documents and Settings). It worked fine when my folder names had no spaces.