I'm trying to create a virtual environment in Python, but I always get an error no matter how many times I re-install python-setuptools and pip.
My computer is running Windows 8, and I'm using Python 3.3.
E:\Documents\proj>virtualenv venv --distribute
Using base prefix 'c:\\Python33'
New python executable in venv\Scripts\python.exe
Installing setuptools, pip...
Complete output from command E:\Documents\proj\venv\Scripts\python.exe -c "imp
ort sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\pip-1.5-py2.py3-none-any.whl\pip\__init__.py", line 9, in <module>
File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\pip-1.5-py2.py3-none-any.whl\pip\log.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 2696, in <modul
e>
File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 429, in __init_
_
File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 443, in add_ent
ry
File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 1722, in find_i
n_zip
File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 1298, in has_me
tadata
File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 1614, in _has
File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 1488, in _zipin
fo_name
AssertionError: c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\EGG-INFO
\PKG-INFO is not a subpath of c:\Python33\lib\site-packages\virtualenv-1.11-py3.
3.egg\virtualenv_support\setuptools-2.0.2-py2.py3-none-any.whl\
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "C:\Python33\Scripts\virtualenv-script.py", line 9, in <module>
load_entry_point('virtualenv==1.11', 'console_scripts', 'virtualenv')()
File "C:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv.py",
line 820, in main
symlink=options.symlink)
File "C:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv.py",
line 988, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "C:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv.py",
line 956, in install_wheel
'PIP_NO_INDEX': '1'
File "C:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv.py",
line 898, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command E:\Documents\proj\venv\Scripts\python.exe -c "import sys, pip;
pip...ll\"] + sys.argv[1:])" setuptools pip failed with error code 1
I've found a solution to this problem. Only the latest virtualenv (v1.11) which was released just a few days ago has this problem. Remove the egg from your site-packages folder and install the previous version via easy_install virtualenv==1.10.1, virtualenv will work fine.
I install virtulaenvwrapper-win and upgrade my virtualenv version to latest (1.11.5) with command:
pip install virtualenv --upgrade
If i write:
mkvirtualenv demo --system-site-packages --python=C:\Python34\python.exe
i see:
python.exe: can't open file 'C:\Python34\Scripts\virtualenv-script.py': [Errno 2] No such file or directory
Solution - using virtualenv, non virtualenvwrapper:
cd C:\www\virtualenvs
virtualenv demo --system-site-packages --python=C:\Python34\python.exe
Now i use workon only for activate/deactivate virtual environment.
System: Windows 8.1 x64
With virtualenvwraper==4.7.1 (and probably above), one could just edit mkvirtualenv.bat like this:
uncomment line 48 (remove REM):
virtualenv.exe %*
comment line 49 (add REM)
REM python.exe "%PYHOME%\Scripts\virtualenv-script.py" %ARGS%
Related
Before someone slaps my hand, I had installed venv/virtualenv to setup virtual environments but I had other issues so someone suggested I upgrade my pip3 version to the current version (22.0.4 right now)
I somehow messed up both pip and pip3 so hopefully someone can help me.
I tried to upgrade my version of pip on my Ubuntu 16.04 box by running
pip3 install --upgrade pip
I also tried running
pip3 install --upgrade pip3
After upgrading, I kept getting errors when trying to run pip3 so I removed it, planning to install with the get-pip.py script.
However, now when I try to install pip3 using
sudo python3 /tmp/get-pip.py
I keep getting an AttributeError:
$ sudo python3 /tmp/get-pip.py
Traceback (most recent call last):
File "/tmp/get-pip.py", line 27077, in <module>
main()
File "/tmp/get-pip.py", line 135, in main
bootstrap(tmpdir=tmpdir)
File "/tmp/get-pip.py", line 111, in bootstrap
monkeypatch_for_cert(tmpdir)
File "/tmp/get-pip.py", line 92, in monkeypatch_for_cert
from pip._internal.commands.install import InstallCommand
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/tmp/tmpu1lmh2fr/pip.zip/pip/_internal/commands/__init__.py", line 9, in <module>
...
...
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/tmp/tmpu1lmh2fr/pip.zip/pip/_vendor/pyparsing.py", line 5677, in <module>
File "/tmp/tmpu1lmh2fr/pip.zip/pip/_vendor/pyparsing.py", line 1488, in setResultsName
File "/tmp/tmpu1lmh2fr/pip.zip/pip/_vendor/pyparsing.py", line 1491, in _setResultsName
File "/tmp/tmpu1lmh2fr/pip.zip/pip/_vendor/pyparsing.py", line 1445, in copy
AttributeError: module 'copy' has no attribute 'copy'
Can someone point me to instructions on how to re-install pip/pip3 or how to get around this AttributeError? Hopefully the solution will also keep my old modules that I had downloaded from before too. Thanks
Check if there is a file /tmp/copy.py or directory+file /tmp/copy/__init__.py. Try these commands: sudo python3 -c "import copy; print(copy.copy)" and sudo python3 -c "import copy; print(copy.__file__)"
If any of those exists it will be imported instead of standard module copy because Python prepends the directory of a script (the script is /tmp/get-pip.py, the directory /tmp/) at the beginning of sys.path so it's where Python starts to find modules/packages.
I'm having trouble figuring this one out -- when trying to install a package (zipline in this case), it's struggling to find the setuptools.build_meta file, which I DO HAVE in the site-packages\setuptools directory. As ignorant as I am, I tried dropping this file into the site-packages\pip_vendor\pep517 directly with no change. I'm sure this is simple, but I'm not seeing it. Any help would be appreciated!
The trace back is below.
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\justjo\PycharmProjects\python35_venv\lib\site-packages\pip\_internal\cli\base_command.py", line 186, in _main
status = self.run(options, args)
File "C:\Users\justjo\PycharmProjects\python35_venv\lib\site-packages\pip\_internal\commands\install.py", line 331, in run
resolver.resolve(requirement_set)
File "C:\Users\justjo\PycharmProjects\python35_venv\lib\site-packages\pip\_internal\legacy_resolve.py", line 177, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "C:\Users\justjo\PycharmProjects\python35_venv\lib\site-packages\pip\_internal\legacy_resolve.py", line 333, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "C:\Users\justjo\PycharmProjects\python35_venv\lib\site-packages\pip\_internal\legacy_resolve.py", line 282, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "C:\Users\justjo\PycharmProjects\python35_venv\lib\site-packages\pip\_internal\operations\prepare.py", line 516, in prepare_linked_requirement
req, self.req_tracker, self.finder, self.build_isolation,
File "C:\Users\justjo\PycharmProjects\python35_venv\lib\site-packages\pip\_internal\operations\prepare.py", line 95, in _get_prepared_distribution
abstract_dist.prepare_distribution_metadata(finder, build_isolation)
File "C:\Users\justjo\PycharmProjects\python35_venv\lib\site-packages\pip\_internal\distributions\sdist.py", line 38, in prepare_distribution_metadata
self._setup_isolation(finder)
File "C:\Users\justjo\PycharmProjects\python35_venv\lib\site-packages\pip\_internal\distributions\sdist.py", line 96, in _setup_isolation
reqs = backend.get_requires_for_build_wheel()
File "C:\Users\justjo\PycharmProjects\python35_venv\lib\site-packages\pip\_vendor\pep517\wrappers.py", line 152, in get_requires_for_build_wheel
'config_settings': config_settings
File "C:\Users\justjo\PycharmProjects\python35_venv\lib\site-packages\pip\_vendor\pep517\wrappers.py", line 255, in _call_hook
raise BackendUnavailable(data.get('traceback', ''))
pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
File "C:\Users\justjo\PycharmProjects\python35_venv\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 63, in _build_backend
obj = import_module(mod_path)
File "C:\Program Files\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 985, in _gcd_import
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
ImportError: No module named 'setuptools.build_meta'
So for anyone having the same error I solved this by downloading the package directly and deleting the pyproject.toml file, then cd path\setup.py and "pip install ." in a terminal/cmd.
In my case, i downgraded my pip version to 9.0.1 using python -m pip install pip==9.0.1 and it worked for me
I resolved it by upgrading setuptools version to the latest:
sudo /usr/bin/python3.9 /usr/bin/pip3 install setuptools==58.0.4
Other versions:
/usr/bin/python3.9 /usr/bin/pip3 --version
pip 20.0.2 from /usr/lib/python3.9/dist-packages/pip (python 3.9)
/usr/bin/python3.9 --version
Python 3.9.5
lsb_release -d
Description: Ubuntu 20.04.2 LTS
uname -srvi
Linux 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64
1.first:
Install Oscar and its dependencies within a virtualenv:
git clone https://github.com/django-oscar/django-oscar.git
cd django-oscar
ll
virtualenv oscar
. ./oscar/bin/activate
sandbox/manage.py runserver
python -m pip install django
pip install --upgrade pip
python -m pip install django
sandbox/manage.py runserver
pip install -r requirements.txt
sandbox/manage.py runserver
2.this is my version:
(oscar)[root#node02 django-oscar]# python --version
Python 3.5.1
(oscar)[root#node02 django-oscar]# django-admin --version
1.11.1
(oscar)[root#node02 django-oscar]#
3.this is error:
CentOS Linux release 7.1.1503 (Core)
(oscar)[root#node02 django-oscar]# sandbox/manage.py runserver
Traceback (most recent call last):
File "sandbox/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/root/django-oscar/oscar/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/root/django-oscar/oscar/lib/python3.5/site-packages/django/core/management/__init__.py", line 307, in execute
settings.INSTALLED_APPS
File "/root/django-oscar/oscar/lib/python3.5/site-packages/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File "/root/django-oscar/oscar/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/root/django-oscar/oscar/lib/python3.5/site-packages/django/conf/__init__.py", line 110, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/root/django-oscar/oscar/lib64/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/root/django-oscar/sandbox/settings.py", line 3, in <module> oscar?
import oscar
ImportError: No module named 'oscar'
thank you
For anyone having this problem -
Please make sure you have done the following:
python3 -m venv MY_ENV
source MY_ENV/bin/activate
pip3 install django-oscar
Note: pip3/python3 can be replaced with pip/python - depending on version
I am trying to install readthedocs in local system (Ubuntu 14.04 ) in python3 virtual env from the instructions given in this link
When I ran pip3 install -r requirements.txt , I got an error for Distutils2 . I removed that dependency as the distutils2 is no longer supported and assumed setuptools would suffice.
Running this command python manage.py migrate gave the below error :
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/contrib/admin/__init__.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/username/read_the_docs_env/lib/python3.4/site-packages/django/utils/module_loading.py", line 74, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/home/username/read_the_docs_env/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/username/Desktop/CurrentProjects/read_the_docs/checkouts/readthedocs.org/readthedocs/core/admin.py", line 10, in <module>
from readthedocs.core.views import SendEmailView
File "/home/username/Desktop/CurrentProjects/read_the_docs/checkouts/readthedocs.org/readthedocs/core/views/__init__.py", line 26, in <module>
from readthedocs.projects.tasks import remove_dir
File "/home/username/Desktop/CurrentProjects/read_the_docs/checkouts/readthedocs.org/readthedocs/projects/tasks.py", line 493
print "Sync Versions Exception: %s" % e.message
^
SyntaxError: Missing parentheses in call to 'print'
I understand from the above stacktrace that the code is in python2 and so print statement is different in python3 .
Does this mean that I have to install readthedocs in python2 virtualenv ?
Can't we host the docs of python3 projects in readthedocs in-house server ?
The read the docs code does not support Python 3 yet. The installation instructions explicitly say to use Python 2.7:
First, obtain Python 2.7 and virtualenv
However, it should still be possible to use your read the docs installation to host docs for Python 3 projects, since the instructions then say:
If you plan to import Python 3 project to your RTD then you’ll need to install Python 3 with virtualenv in your system as well.
I ran "sudo easy_install3 py-notify" and had my setuptools updated to the current version (15), all my stuff is updated and upgraded. I don't understand why it can't detect setuptools.
It says I need 3.3
But I have 15, so how is it not working
$ sudo easy_install3 py-notify
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/setuptools-15.0-py3.4.egg/pkg_resources/__init__.py", line 639, in _build_master
File "/usr/local/lib/python3.4/dist-packages/setuptools-15.0-py3.4.egg/pkg_resources/__init__.py", line 940, in require
File "/usr/local/lib/python3.4/dist-packages/setuptools-15.0-py3.4.egg/pkg_resources/__init__.py", line 832, in resolve
pkg_resources.VersionConflict: (setuptools 15.0 (/usr/local/lib/python3.4/dist-packages/setuptools-15.0-py3.4.egg), Requirement.parse('setuptools==3.3'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/easy_install3", line 5, in <module>
from pkg_resources import load_entry_point
File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "/usr/local/lib/python3.4/dist-packages/setuptools-15.0-py3.4.egg/pkg_resources/__init__.py", line 3057, in <module>
File "/usr/local/lib/python3.4/dist-packages/setuptools-15.0-py3.4.egg/pkg_resources/__init__.py", line 641, in _build_master
File "/usr/local/lib/python3.4/dist-packages/setuptools-15.0-py3.4.egg/pkg_resources/__init__.py", line 654, in _build_from_requirements
File "/usr/local/lib/python3.4/dist-packages/setuptools-15.0-py3.4.egg/pkg_resources/__init__.py", line 827, in resolve
pkg_resources.DistributionNotFound: The 'setuptools==3.3' distribution was not found and is required by the application
if you have pip you can use: pip list to see all installed modules. if you can't see setuptools, install it manually.