1

i don't have a clue how to install packages but when i copy and paste what websites show, it always comes up with a syntax error

pip3 install cryptography SyntaxError: invalid syntax

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
  • 4
    Did you executed this code in terminal or python interpreter? – Mert Köklü Nov 09 '19 at 22:43
  • You might be copying special end of line characters. Try to write the command yourself – Victor Deleau Nov 09 '19 at 22:44
  • 1
    Check out [how to install packages using pip](https://packaging.python.org/tutorials/installing-packages/#ensure-you-can-run-python-from-the-command-line). Make sure you're entering the commands into the command line rather than the python interpreter. – Ari Cooper-Davis Nov 09 '19 at 22:44

4 Answers4

0

First of all, you need to make sure python is added to your path.

Here is a tutorial. Where basically, you need to find where your python is installed, copy the path, and paste to the advanced environment settings as shown in the tutorial.

Once you have done, you can run your command prompt, run python, see if things work.

If it works, you can now run pip install cryptography :)

For Mac users:

Try which python and which pip at your terminal

Angus
  • 3,680
  • 1
  • 12
  • 27
0

Are you running it in the python interpreter? Or the command line? (also called the terminal). You should be running it in the command line.

Python interpreter is for running python programs, ".py" files. Once you install "cryptography" module in the command line using the command "pip3 install cryptography" use this module in the python interpreter by importing it using the line:

import cryptography
Sushanth
  • 2,224
  • 13
  • 29
0

On Windows, you need to make sure your PATH is configured correctly. Pip is a python module usually stored in a subdirectory of Python itself.

Did you set up the PYTHONPATH environment variable correctly? In your environment variables (Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables) System Variables section, you should have PYTHONPATH pointing to the Python install. (On my machine, this is "C:\Users[your user profile]\AppData\Local\Programs\Python").

Then, in the Command Prompt (which you can access by pressing win+r and then typing cmd in the resulting window), you call pip as a module of python: python -m pip install cryptography

  • there isn't one, can you tell me how to create one? – Evan Dilkes Nov 09 '19 at 23:04
  • i got it yas thanks – Evan Dilkes Nov 09 '19 at 23:10
  • From the Environment Variables tab, press "New" under "System Variables". The Variable Name should be `PYTHONPATH`. The Variable Path should be the path (address) to your python install. You'll probably need to search your file system for that if you don't remember where you installed it. – Milan Capoor Nov 09 '19 at 23:39
0

A simple way to properly install python and avoiding having to manage path is:

  1. Install Anaconda. Anaconda will install python for you in a virtuall environment, and will seat in ~\anaconda3. Anaconda will also update your .bashrc or .bash_profile setting the proper path for python. The Pyhton version installed will be python 3 (at current date).
    1. In your terminal now conda install pip. Now you can use pip without encountering any error. As explained in the answer here:

pip3 and pip would make a difference only when you are not using any environment managers like virualenv (or) conda. Now as you are creating a conda environment which has python==3.x, pip would be equivalent to pip3.

nicdelillo
  • 517
  • 5
  • 13