[PYTHON] Error when entering virtual environment with workon command

I want to enter the virtual environment with the workon command

I want to enter the virtual environment created by virtualenv warapper with the workon command.

$ workon myvenv(Virtual environment name)

I should be able to enter this, but I get the following error.

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Library/Python/2.7/site-packages/virtualenvwrapper/hook_loader.py", line 16, in <module>
    from stevedore import ExtensionManager
ImportError: No module named stevedore
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Library/Python/2.7/site-packages/virtualenvwrapper/hook_loader.py", line 16, in <module>
    from stevedore import ExtensionManager
ImportError: No module named stevedore

I can enter the virtual environment, but I get an error. Apparently there is no module called stevedore.

Work environment: macOS Sierra version 10.12.5 Python 2.7.10 virtualenv 15.1.0 virtualenvwrapper 4.7.2

counter-measure

Install stevedore.

$ sudo pip install stevedore

I get an error again.

Collecting stevedore
  Downloading stevedore-1.25.0-py2.py3-none-any.whl
Requirement already satisfied: pbr!=2.1.0,>=2.0.0 in /Library/Python/2.7/site-packages (from stevedore)
Collecting six>=1.9.0 (from stevedore)
  Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six, stevedore
  Found existing installation: six 1.4.1
    DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/var/folders/7t/313m_dg1067bhtr2llqd0q9cz8c4fj/T/pip-KG9_ld-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

When I looked it up, it seems that the cause was that six was already included. Try installing again with the following command.

$ sudo pip install stevedore --upgrade --ignore-installed six

The error is now gone.

References

http://qiita.com/kawashinji/items/98fd8a917a17c3476091 https://github.com/pypa/pip/issues/3165

Recommended Posts

Error when entering virtual environment with workon command
Virtual environment with Python 3.6
Error when playing with python
Switch virtual environment with jupyter
Activate Anaconda's virtual environment with PowerShell
When coverage fails with _sqlite3 error
Error when building mac python environment
Build python virtual environment with virtualenv
[Personal memo] Python virtual environment command memo
Create a virtual environment with Python!
Building a virtual environment with Python 3
PATH when using ANACONDA virtual environment with Pycharm (as of Mac 2020/10/03)
Debug settings in virtual environment when using Pipenv with VS Code
A story when a directory is buggy with the django-admin start project command in a virtual environment using Pipenv
Note when creating an environment with python
Error "Entry point not found" when starting Jupyter Notebook in virtual environment
[Python] Create a virtual environment with Anaconda
When I get an error with PyInstaller
Create a virtual environment with Python_Mac version
Automatically switch virtual environment with conda + direnv
Build a python virtual environment with pyenv
When I tried to create a virtual environment with Python, it didn't work
I got an error when saving with OpenCV
Recommended environment and usage when developing with Python
Start Django in a virtual environment with Pipenv
Python (Windows 10) Virtual Environment / Package with VS Code
Try using conda virtual environment with Jupyter Notebook
[Memo] Build a virtual environment with Pyenv + anaconda
A memo when creating a python environment with miniconda
Build a virtual environment with pyenv and venv
Work in a virtual environment with Python virtualenv.
Flow of creating a virtual environment with Anaconda
Rollback processing when an error occurs with fabric
From Python environment construction to virtual environment construction with anaconda
Error running Jupyter Notebook in Anaconda virtual environment
Use anaconda virtual environment with Zsh (problem fix)
Procedure when building Ubuntu as a virtual environment with Vagrant + Virtualbox for LPIC Level 1.
Beginner virtual environment
Virtual environment construction with Docker + Flask (Python) + Jupyter notebook
pip install ○○○ error Command errored out with exit status 1:
Build a python virtual environment with virtualenv and virtualenvwrapper
Create a virtual environment with Anaconda installed via Pyenv
code-server Online environment (2) Create a virtual network with Boto3
Simplified Path input when enabling virtual environment in venv
Build a python virtual environment with virtualenv and virtualenvwrapper
Command line collection for using virtual environment in Anaconda
A memorandum when an error occurs with pip install
Notes on creating a virtual environment with Anaconda Navigator
I got an error when using Tensorboard with Pytorch
Ssh to virtual environment with remote development of vscode
Build a Django environment for Win10 (with virtual space)
Implemented pix2pix in Windows environment (with kind command line execution results and common error examples)
[RHEL7 / CentOS7] LWP execution error in the environment where Perl is installed with the yum command