6

So, I installed virtualenv in ubuntu terminal. I installed using the following commands:

sudo apt install python3-virtualenv
pip install virtualenv

But when I try creating a new virtualenv using:

virtualenv -p python3 venv

I am getting the following error:

AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsArmFramework'

How can I solve it?

Phoenix
  • 213
  • 4
  • 14

6 Answers6

17

I had a similar experience. The reason for this is that I did it by installing two virtualenv with apt and pip3.

pip3 uninstall virtualenv


virtualenv my-python3
daesoo9200
  • 196
  • 2
  • I got the error while updating dependencies with poetry. Uninstalling `virtualenv` package that was present in the venv (probably as subdependency of other packages) solved the issue for me. – mattiatantardini May 03 '22 at 13:45
6

You don't need to use virtualenv. You can use this:

python3 -m venv ./some_env
user17558100
  • 635
  • 11
2

First off, just one of

sudo apt install python3-virtualenv
pip install virtualenv

should do. You do not need the pip command if the apt installation worked.

Second, you should be able to create one where you can write:

edd@rob:/tmp$ mkdir venvdemo
edd@rob:/tmp$ cd venvdemo/
edd@rob:/tmp/venvdemo$ virtualenv -p python3 venv
created virtual environment CPython3.9.5.final.0-64 in 162ms
  creator CPython3Posix(dest=/tmp/venvdemo/venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/edd/.local/share/virtualenv)
    added seed packages: pip==20.3.4, pkg_resources==0.0.0, setuptools==44.1.1, wheel==0.34.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
edd@rob:/tmp/venvdemo$ 
edd@rob:/tmp/venvdemo$ ls -a 
.  ..  venv
edd@rob:/tmp/venvdemo$ ls -a venv/
.  ..  bin  .gitignore  lib  pyvenv.cfg
edd@rob:/tmp/venvdemo$ 

(and I did this on an Ubuntu machine).

Third, something is still very wrong because with Ubuntu you should not get an error message for CPython2macOsArmFramework.

Dirk Eddelbuettel
  • 347,098
  • 55
  • 623
  • 708
0

There is no need to use virtualenv anymore. Since Python3.3, you can use venv to create virtual environments.

python3 -m venv ./desired_name_of_env
gold_cy
  • 12,080
  • 3
  • 20
  • 42
0

I had a similar problem

sudo virtualenv venv

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 03 '22 at 18:09
0

I got the same error when creating the environment.
However, I was trying to create it through my WSL Ubuntu 20.04 LST.
After some research, someone in the comment section of this post suggested adding sudo when creating the environment could resolve the issue, which works for me.

sudo virtualenv venv

Now, I am not sure why adding sudo works. My guess is that without superuser permission, WSL cannot create a folder for the local machine.