aspiring1
aspiring1

Reputation: 446

PermissionError: [Errno 13] Permission denied on using virtualenv and virtualenvwrapper with pip-20.0.2-py2.py3-none-any.whl wheel file

I usually use virtualenv and virtualenvwrapper for creating virtualenvironments for my projects. On trying to create a new virtualenvironment using the following command:

mkvirtualenv -a . -p python3.7 venv

I get the following error message:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/virtualenv/seed/via_app_data/via_app_data.py", line 75, in _get
    self.app_data,
  File "/home/ubuntu/.local/lib/python3.6/site-packages/virtualenv/seed/embed/wheels/acquire.py", line 28, in get_wheels
    acquire_from_bundle(processed, for_py_version, wheel_cache_dir)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/virtualenv/seed/embed/wheels/acquire.py", line 57, in acquire_from_bundle
    copy2(str(bundle), str(bundled_wheel_file))
  File "/usr/lib/python3.6/shutil.py", line 263, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.6/shutil.py", line 121, in copyfile
    with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: '/home/ubuntu/.local/share/virtualenv/seed-app-data/v1.0.1/3.7/wheels/pip-20.0.2-py2.py3-none-any.whl'

created virtual environment CPython3.7.9.final.0-64 in 257ms
  creator CPython3Posix(dest=/home/ubuntu/.virtualenvs/cosine, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/home/ubuntu/.local/share/virtualenv/seed-app-data/v1.0.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
Setting project for cosine to /home/ubuntu/cosine_similarity

With the virtualenvironment being created still, on running :

pip -V

I get

pip 20.1 from /home/ubuntu/.local/lib/python3.6/site-packages/pip (python 3.6)

Which is pip associated with the default python version on the server and therefore, I uninstalled python3.7, and on running python3.7 on my terminal got:


Command 'python3.7' not found, but can be installed with:

sudo apt install python3.7-minimal

Thus on the assumption that python3.7 wasn't installed properly, I again re-installed it using the ppa from deadsnakes as follows:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt install python3.7

But sadly I am still running into the same error, I am using poetry on top of the virtualenvironment and on running the following:( I have the poetry.lock file)

poetry install

I get the following error message:

[CalledProcessError]
Command '['/home/ubuntu/.cache/pypoetry/virtualenvs/cosine-similarity-SzdRNlpw-py3.7/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

Would be great if someone can explain why this is happening and how to solve this in turn, thanks.

[EDIT]

Adding more information when I use -p python3.6, I don't get any such permission errors and my virtualenvironment is created successfully.

For additional information, I installed python3.8 on the system using the above ppa by deadsnakes* and then attempted to create a virtualenvironment with python3.8.

Command mkvirutalenv -a . -p python3.8 venv2

The output in stdout is as follows:

created virtual environment CPython3.8.5.final.0-64 in 627ms
  creator CPython3Posix(dest=/home/ubuntu/.virtualenvs/venv2, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/home/ubuntu/.local/share/virtualenv/seed-app-data/v1.0.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/venv2/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/venv2/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/venv2/bin/preactivate
virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/venv2/bin/postactivate
virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/venv2/bin/get_env_details
Setting project for venv2 to /home/ubuntu/main_xyz/app

Upvotes: 1

Views: 16914

Answers (1)

Precious Tom
Precious Tom

Reputation: 495

Before you try this solution, try running sudo su Then repeat your solution,... If it works cool. Else

Part 2 ======>

Check your python version. python --version

Find all python within python ls /usr/bin/python*

If python 3.7 is part of the listed path, cool.

Set python default path alias python='/usr/bin/python3.7'

Re login your source . ~/.bashrc

Confirm that your version of python has changed python --version

Then install virtual environment pip install virtualenv

Then create a virtual environment virtualenv venv

And activate it source venv/bin/activate

Upvotes: 3

Related Questions