0

I uninstalled Virtualenv 16.6.0. I'm using PyCharm with virtualenv version 15.1.0. Update: Tried the creating /venv in create projects but the message is this there and now the venv directory is yellow. When I type virtualenv I get:

Running virtualenv with interpreter /usr/bin/python2
You must provide a DEST_DIR
Usage: virtualenv.py [OPTIONS] DEST_DIR

Everything else runs Python 3.7

apt policy python3-django
python3-django:
  Installed: 1:1.11.20-1ubuntu0.2
  Candidate: 1:1.11.20-1ubuntu0.2
  Version table:
 *** 1:1.11.20-1ubuntu0.2 500

raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"

apt policy python3-virtualenv
python3-virtualenv:
  Installed: 15.1.0+ds-2
  Candidate: 15.1.0+ds-2

sudo apt install python3-virtualenv
python3-virtualenv is already the newest version (15.1.0+ds-2).
python3-virtualenv set to manually installed.

Update: Tried both commands

sudo apt install python3-pip
python3-pip is already the newest version (18.1-5).

pip3 install virtualenv
Requirement already satisfied: virtualenv in /usr/lib/python3/dist-packages (15.1.0)

enter image description here

enter image description here

enter image description here

enter image description here

SeemsToBeStuck
  • 145
  • 2
  • 8
  • 17

2 Answers2

0

Install virtualenv with pip3 and it will default to using python3 as the interpreter

sudo apt install python3-pip
pip3 install virtualenv

If all you are looking to do is set your virtual environment to python3 then you would use the command

virtualenv -p /usr/bin/python3.x (name of your environment here)

For PyCcharm to use python3 you have to do it from within PyCharm itself. The remainder of my response is taken directly from https://www.cs.rit.edu/~csci141/Docs/PyCharm-Setup.html.

On the welcome screen, go to the lower right of the window and select Configure -> Settings (or Preferences) -> Default Project -> Project Interpreter.

In the settings window, you will now configure the default projects you make in PyCharm to use Python 3.

When the setting dialog comes up, select the Project Interpreter to choose the Python 3 interpreter that you just installed.

Turn off the default use of venv for projects. You should see a settings button (e.g. gear) for adding an interpreter. Instead, choose the system interpreter to override the venv.

Now select the OK button at the bottom and PyCharm will do the updates back on the welcome screen.

You will now turn off the style warnings for what's known as "PEP 8", Python's style enforcement. (We do not use standard Python style in this course.) You do this by opening the preferences, selecting "Inspections" under Editor -> CodeStyle, and unchecking the "PEP 8" violation checkboxes as shown below. You can search for "pep" to find this more quickly than scrolling.

Finally you can turn off the authorship line in the Editor's Code Templates for Python by erasing the whole line containing the author text in the template; you can see the line in the screen below. (You may want to visit the templates later to customize them.)

You can then use the following code to test your settings. NOTE python3-tk must be installed sudo apt install python3-tk

 """ sample.py is a sample python3 program using turtle graphics. """

 python  import turtle    def drawSquare():
 """
 drawSquare draws a square with sides of length 100.
 """
 turtle.forward(100)
 turtle.left(90)
 turtle.forward(100)
 turtle.left(90)
 turtle.forward(100)
 turtle.left(90)
 turtle.forward(100)
 turtle.left(90)    def main():
 """
 main program draws a square and waits user to hit Enter key.
 """
 drawSquare()
 print('Close the canvas window to end the program...')
 turtle.done()    if __name__ == '__main__':
 main() 

You can first run the code by right-clicking in the code window and selecting Run sample. If everything is correct, you should see a separate Python turtle drawing window come up, and the console should open in the bottom pane of PyCharm.

karel
  • 110,292
  • 102
  • 269
  • 299
Gordster
  • 1,679
  • 11
  • 21
0

All I had to on PyCharm-was the click on the bottom right of the screen, the current interpreter- change to Python 3 - then it installed Python 3.8 on Pycharm.

SeemsToBeStuck
  • 145
  • 2
  • 8
  • 17