I'm trying to figure out why I cannot create a virtualenv on RedHat. Here's my command line :
python /opt/rh/python27/root/usr/bin/virtualenv-2.7 -p /opt/rh/python27/ /home/myuser/tpa/
.
/opt/rh/python27/root/usr/bin/virtualenv-2.7 : Is here to setup the version of virtualenv that I want to use
-p /opt/rh/python27/ : To setup the version of python I want to use
/home/myuser/tpa/ : My directory where the virtualenv will be stored
But I get the following :
Traceback (most recent call last):
File "/opt/rh/python27/root/usr/bin/virtualenv-2.7", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 2603, in <module>
File "/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 666, in require
File "/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 565, in resolve
pkg_resources.DistributionNotFound: virtualenv==1.10.1
Do you have any idea?
Thanks
-p expects a python executable, not an installation directory. Give it the name of a python executable in your $PATH or the full path the the python executable you want to run.
Related
I want to learn django so I tried to create a virtual env and I am getting this error:
mkvirtualenv django
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 2881, in <module>
parse_requirements(__requires__), Environment()
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 596, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: virtualenv==1.8.2
I haven't used python in a while so i'm not sure what the issue is:
virtualenv --version
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 2881, in <module>
parse_requirements(__requires__), Environment()
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 596, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: virtualenv==1.8.2
You're using mkvirtualenv which is a virtualenvwrapper command. You probably do not have virtualenvwrapper installed.
Type virtualenvwrapper in your command line and observe the input. If you get something like command not found, then you should install it first.
You should install it with pip like so pip install virtualenvwrapper.
There are some post-installation steps, the most important one being source /usr/local/bin/virtualenvwrapper.sh that makes commands like mkvirtualenv, rmvirtualenv available.
See virtualenvwrapper's documentation.
Alternatively, you can also just make use of virtualenv. Check that you have it installed like so
virtualenv --version
If you do not, you can install it with pip. Once you have it installed, you can create your virtualenv like so
virtualenv <name> in the directory of your choice.
tox runs my Python 2.7 tests, but fails for Python 3.4. It gives an "Invocation failed" message. Excerpts:
py34 create: /home/josh/code/ezoutlet/.tox/py34
ERROR: invocation failed (exit code 1), logfile: /home/josh/code/ezoutlet/.tox/py34/log/py34-0.log
ERROR: actionid: py34
msg: getenv
cmdargs: ['/usr/bin/python', '-m', 'virtualenv', '--python', '/usr/bin/python3.4', 'py34']
And later
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 8, in <module>
import base64
File "/usr/lib/python3.4/base64.py", line 9, in <module>
import re
File "/usr/lib/python3.4/re.py", line 336, in <module>
import copyreg
File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 53, in apport_excepthook
if not enabled():
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled
import re
File "/usr/lib/python3.4/re.py", line 336, in <module>
import copyreg
File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Original exception was:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 8, in <module>
import base64
File "/usr/lib/python3.4/base64.py", line 9, in <module>
import re
File "/usr/lib/python3.4/re.py", line 336, in <module>
import copyreg
File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Running virtualenv with interpreter /usr/bin/python3.4
ERROR: InvocationError: /usr/bin/python -m virtualenv --python /usr/bin/python3.4 py34 (see /home/josh/code/ezoutlet/.tox/py34/log/py34-0.log)
You need to look at the details of the error message. Notice the command that failed (from the first excerpt):
cmdargs: ['/usr/bin/python', '-m', 'virtualenv', '--python', '/usr/bin/python3.4', 'py34']
You can run this manually with:
/usr/bin/python -m virtualenv --python /usr/bin/python3.4 py34
Assuming you see the same error, your issue is with virtualenv rather than tox.
I reviewed the virtualenv help page and it seems like this should work. Faced with a possible bug, a good first step is to upgrade Python, virtualenv, or other libraries.
In my case, upgrading virtualenv was the solution:
pip install --upgrade virtualenv
Interestingly, this solution worked on both Windows and Linux. Most likely, there was a bug fix between when I got virtualenv and the latest release.
I'm trying to use the virtualenvwrapper to make a python 3 based virtualenv. However,I'm when I pass the optional interpreter argument, I'm seeing this error. I'm running Ubuntu 15.04. I tried reinstalling virtualenv and virtualenvwrapper without success. Thanks for all your help!
$ mkvirtualenv scriptcutter --python=/usr/bin/python3
Running virtualenv with interpreter /usr/bin/python3
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 8, in <module>
import base64
File "/usr/lib/python3.4/base64.py", line 9, in <module>
import re
File "/usr/lib/python3.4/re.py", line 336, in <module>
import copyreg
File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 53, in apport_excepthook
if not enabled():
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled
import re
File "/usr/lib/python3.4/re.py", line 336, in <module>
import copyreg
File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Original exception was:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 8, in <module>
import base64
File "/usr/lib/python3.4/base64.py", line 9, in <module>
import re
File "/usr/lib/python3.4/re.py", line 336, in <module>
import copyreg
File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
I come across same issue, but after I downgrade virtualenv to 12.0.2, this problem disappears.
This is sort of a workaround for now.
Create a virtualenv using pyvenv.
# install pyvenv on Ubuntu
sudo apt-get install python3-venv
To minimize disruption in your normal workflow, pass a destination directory that is the same as the one used by virtualenvwrapper Like so,
pyvenv example ~/.virtualenvs/example
This is automatically working with workon and cdproject commands. I don't use much else that is provided by virtualenvwrapper
Hope this helps.
You can upgrade to the most recent version of virtualenv, with:
sudo pip install --upgrade https://github.com/pypa/virtualenv/archive/master.zip
virtualenv --version
# Returns 15.2.0.dev0 when I ran it
The following command then works:
mkvirtualenv scriptcutter --python=/usr/bin/python3
Apparently, the develop branch was dropped, so the URL with "develop" will no longer work. My answer was based off of #pjotr_dolphin's comment, with the URL updated.
I am trying to build an installer for a sage script using setuptools. Here is what I have.
My setup.py file:
#!/usr/bin/env python2
from setuptools import setup
__name__ = 'sage-test'
__version__ = '0.0'
setup(name=__name__,
scripts=['sage-test'],
)
The sage-test file:
#!/usr/bin/env sage
from sage.all import GF
print(GF(5))
I now do ./setup.py build and ./setup.py install. When I try to run sage-test, I get the following error:
Traceback (most recent call last):
File "/usr/bin/sage-test", line 4, in <module>
__import__('pkg_resources').run_script('sage-test==0.0.0', 'sage-test')
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 517, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1443, in run_script
exec(script_code, namespace, namespace)
File "/usr/lib/python2.7/site-packages/sage_test-0.0.0-py2.7.egg/EGG-INFO/scripts/sage-test", line 3, in <module>
__requires__ = 'sage-test==0.0.0'
ImportError: No module named sage.all
Any ideas how to get this to work? (Note that I can run ./sage-test within the current directory and everything works.)
This may not help, but this looks suspicious.
/usr/lib/python2.7/
Maybe you need to do everything within sage -sh - I wouldn't be surprised if there was some env var that was not set up properly. I don't know exactly why but maybe it's picking up your system Python somehow.
I have installed python under /opt/python2.7.1/ on CentOS machine which has already python2.4 and configure it to run python2.7 default.
However, when I write 'easy_install' it raises error like
Traceback (most recent call last):
File "/opt/python2.7.1/bin/easy_install", line 5, in ?
from pkg_resources import load_entry_point
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2482, in ?
for dist in working_set.resolve(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 483, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: setuptools==0.6c11
I think easy_install under /usr/bin/ links to python2.4. How can I run /opt/python2.7.1/bin/easy_install default?
For $PATH:
/opt/python2.7.1/bin:/usr/devs/bin:/usr/local/bin:/bin:/usr/bin:/home/ops/bin
For $LD_LIBRARY_PATH:
/opt/python2.7.1/lib:
For easy_install:
Traceback (most recent call last):
File "/opt/python2.7.1/bin/easy_install", line 5, in ?
from pkg_resources import load_entry_point
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2482, in ?
for dist in working_set.resolve(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 483, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: setuptools==0.6c11
You have to make use of virtualenv to get things working properly, and without worries in systems with more than one Python version.
Actually, it is quite a help even in system qwith a single Python version, if you have muliple Python apps running.
Visrtualenv will not only take care of setting up all the appropriate environment variables for you to use one Python or another, as it will allow you to use use a separate environment where you can safely "easy_install" Python 2.4 modules without conflicting with CentOS .rpm packages of those same modules.