0

I can't install packages in PyCharm

throws this error

Collecting oktaauth
  Downloading oktaauth-0.2-py2-none-any.whl
Requirement already satisfied: requests>=2.8 in /Library/Python/2.7/site-packages (from oktaauth)
Collecting argparse (from oktaauth)
  Downloading argparse-1.4.0-py2.py3-none-any.whl
Collecting beautifulsoup4>=4.4 (from oktaauth)
  Downloading beautifulsoup4-4.6.0-py2-none-any.whl (86kB)
Installing collected packages: argparse, beautifulsoup4, oktaauth

Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 247, in move_wheel_files
    prefix=prefix,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/locations.py", line 153, in distutils_scheme
    i.finalize_options()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 346, in finalize_options
    self.create_home_path()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 565, in create_home_path
    os.makedirs(path, 0700)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Users/karanj/Library/Python/2.7'

I found soltutions by asking me to try installing it by being root or trying sudo with the command and try installing the package. But I don't want to install the package by appending sudo to it.

Any solutions?

Karan Jain
  • 405
  • 1
  • 7
  • 12

2 Answers2

2

When you start a python project, always use Python virtual environemnt. Avoid using use sudo pip install.

You can either

  1. create Pycharm virtual environment, or
  2. Create your typical virtualenv, then add external virtualenv to Pycharm, or
  3. Use pycharm with conda, another virtual environment.
mootmoot
  • 12,845
  • 5
  • 47
  • 44
0

Try with sudo If there is a requirement file e.g. sudo pip install -r requirements.txt Or for standalone package

sudo pip install <package-name>
Asad Iqbal
  • 304
  • 4
  • 16
  • I can install packages in the terminal by appending sudo but PyCharm doesn't append sudo. So every time i have to install a package I have to go to the command line and install the package. – Karan Jain Aug 01 '17 at 13:35