3

I've been trying to install simple packages for python such as numpy and pandas, and while I am able to install the package manually from the command line using pip as soon as I try to import it PyCharm can't find it. I have manually configured the path, with no luck.

PyCharm can also not find the packages I want to install itself and produces a connection timeout, this could be because I am working from a secure network.

Still pretty new to python and software dev in general, I apologise in advance if I'm being stupid, but no other similar threads are solving the issue.

I am operating on windows 7. The error I get is:

C:\Users\james.alexander\PycharmProjects\Test.py\venv1\Scripts\python.exe C:/Users/james.alexander/PycharmProjects/Test.py/testfile.py
Traceback (most recent call last):
  File "C:/Users/james.alexander/PycharmProjects/Test.py/testfile.py", line 1, in <module>
    import numpy
ModuleNotFoundError: No module named 'numpy'
Jkind9
  • 742
  • 7
  • 24
  • I should mention I have used atom to program in python, and packages were working fine there but the issue was atom was so slow it was unusable for simple tasks – Jkind9 Feb 16 '18 at 11:11
  • Install using [Link 1](https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html) instead of trying to install it manually. – Shashank Singh Feb 16 '18 at 11:16
  • That's what I meant when I said PyCharm couldn't find the packages, when I follow the steps in the link provided the package list simply refuses to load – Jkind9 Feb 16 '18 at 11:18
  • Check python 'Project Interpreter' in settings. Is it pointing to the same interpreter you used in command line? – Chamath Feb 16 '18 at 11:21
  • I've checked the interpreter, and I've also tried installing packages to a new location too in the same directory as my project. C:\Users\james.alexander\PycharmProjects\Test.py\venv1\Scripts\python.exe Not sure where else I could crease a path too This is one of the paths I've tried, the other was C:\Users\james.alexander\PycharmProjects\Test.py\venv\Scripts\python.exe – Jkind9 Feb 16 '18 at 11:23
  • May be try `Invalidate Cache / Restart` – Chamath Feb 16 '18 at 11:25
  • Have you configured your project interpreter? – Sam Redway Feb 16 '18 at 12:18
  • One year later, did you find any solutions for this? @Jkind9 – Itachi Feb 21 '19 at 08:37
  • I couldn't find a solution to this no, eventually I used visual studio and let it install everything I needed automatically. – Jkind9 Mar 21 '19 at 16:27
  • Does this answer your question? [How do I use installed packages in PyCharm?](https://stackoverflow.com/questions/19885821/how-do-i-use-installed-packages-in-pycharm) – bad_coder Sep 19 '21 at 04:45

4 Answers4

1

I think PyCharm use a virtualenv, installing via pip won't work since it will install the package in your local env.

Check https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html

Gabriel Samain
  • 497
  • 3
  • 10
  • I am unsure what you mean, I've tried too different methods of installation: the first being to use pip to install to a directory that I then tried to get PyCharm to recognise as where packages are kept, the second being to use the normal method of installation which is using the PyCharm inbuilt system. The latter I believe is what you're referring too; the issue is that the packages simply wont load on the list of available packages you can install. – Jkind9 Feb 16 '18 at 11:32
  • `virtualenv` create a new `PATH` and `PYTHONPATH` component and **append** them to the existing environment paths, it doesn't conflict with the global paths which `pip` uses, I think. – Itachi Feb 21 '19 at 08:36
0

Try This:

Step 1: Ctrl+Alt+s

Step 2: Look for Project Interpreter Under Project

Step 3: Look for + In the right corner of prompt box.

Step 4: Search and select your required package. And Install button is just below.

Hayat
  • 1,539
  • 4
  • 18
  • 32
  • Sorry, I've tried to say before that this method doesn't load any of the packages I want to install. I get Error loading package list: connect timed out, which I said in the OP was (I assume) due to being behind a secure network – Jkind9 Feb 16 '18 at 11:38
0

First check the Project Interpreter in your pycharm. File > Settings >Project >Project Interpreter Check the version of python there (python2 or python3) And check if you are using any virtual environment

And see what version python you have installed For python3 you may have to use "pip3 install pkgname" For python2 use "pip install pkgname"

My3
  • 140
  • 1
  • 10
0

In PyCharm, you can install modules from within the app. Simply access your preferences, then under 'Project Interpreter', you will find a table containing your installed modules. To install a new one, click the + symbol on the bottom - left, then search for the appropriate package, e.g. numpy. Once you've found it, simply click 'Install Package'. The module is now installed and ready to use!

EDIT: I've just seen that someone else has already posted this answer, sorry about that :)

Dan Hill
  • 43
  • 5