2

I need to create new virtual environment in PyCharm. There are already some files in the folder.

This is how my project looks like:

enter image description here

I want to create venv in heureka-negativni-reviews

I try: File -> New project.

I switch this settings:

enter image description here

to have Python 3.10 as an interpreter and to create venv in heureka-negativni-reviews

enter image description here

But when I click on create, I got:

enter image description here

EDIT:

I found that I am not able to select Python 3.10 as an interpreter:

enter image description here

But I cannot click OK when I select Python 3.10:

enter image description here

What is the problem, please?

vojtam
  • 1,157
  • 9
  • 34
  • Does it work if you try python3.8? – Tobi208 Jan 27 '22 at 09:52
  • Also does the folder of your project already contain a .idea folder? – Tobi208 Jan 27 '22 at 09:55
  • @Tobi208 No, it does not contain .idea. Yes, it works when I try python 3.8. But I need Python 3.10 – vojtam Jan 27 '22 at 10:15
  • Are you sure your path to python3.10 is correct and if the installation location is valid? ```usr/bin/python3.8``` seems to work but not ```bin/python3.10```. Does ```bin/python3.10``` possibly require root/admin privileges to create a venv? – Tobi208 Jan 27 '22 at 10:22
  • @Tobi208 it might be a problem. See my edit, please – vojtam Jan 27 '22 at 10:30
  • on a command line try `$ python3 --version` if it shows version 3.10.x then try `$ python3 -m venv ` then tell about your results – woodz Jan 27 '22 at 11:39
  • @woodz python3 --version gives me 3.8, python --version gives me 3.10... – vojtam Jan 27 '22 at 11:58
  • 2
    That explains your problem. On a cmd line have you tried `$ python -m venv `, will it do? It should create a venv within python 3.10. Can you also post the results of `$ pip --version` and `$ pip3 --version`? – woodz Jan 27 '22 at 12:32
  • 1
    @woodz When I try `python -m venv venv/` I got `Error: Command '['/home/vojta/Desktop/INTERNET_HANDEL/HEUREKA/heureka-negativni-reviews/venv/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.` Both pip --version and pip3 --version gives `pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)` – vojtam Jan 27 '22 at 12:57
  • 1
    Now we see the reason, why your IDE is not able to create your venv, since the command line isn't either, which is the set of commands your IDE typically uses. Also your python setup seems to be messed. `/home/vojta/Desktop/INTERNET_HANDEL/HEUREKA/heureka-negativni-reviews/venv/bin/python` seems not to be a general system path. It looks that you build your own version of python and installed it by a specific prefix. Installing python correctly is off the topic here – woodz Jan 27 '22 at 15:21
  • would it suit your needs to create a new environment using conda and not with pip? – DanielTuzes Jan 28 '22 at 19:43

2 Answers2

1

Now we see the reason, why your IDE is not able to create your venv, since the command line isn't either, which is the set of commands your IDE typically uses.

The pip and pip3 belongs to python3.8 and that is another problem, if you want to install python packages for python 3.10, which isn't possible this time without system invention.

Also your python setup seems to be messed.

/home/vojta/Desktop/INTERNET_HANDEL/HEUREKA/heureka-negativni-reviews/venv/bin/python

seems not to be a general system path. It looks that you built your own version of python and installed it by a specific prefix. Installing python correctly is off the topic here.

There are different installers for different platforms which provide install instruction inside their archives.

Before doing this, it's recommended to clean up your messed installation first. You may find information here and there.

It could also be, that you are trying to create another venv from within an already sourced venv. Such kind of composed venvs can lead to confusion and that would explain your path above a bit more, which contains /venv/.

Also manually remove all your custom python versions from your /home/vojta/ directory, like $ rm -r /home/vojta/Desktop/INTERNET_HANDEL

woodz
  • 737
  • 6
  • 13
-1

First ensure that the Python interpreter is added to the list available (by adding as an 'Existing environment').

Then add a venv via link

Then drag and drop your existing files to the venv directory. before with venv after drag and drop