Pycharm how to install pip
Pycharm how to install pip
[PyCharm] Introduction to Interpreter, pip and packages
PyCharm is the most well-known IDE of Python, PyCharm is used by many Python developers to develop projects. Today, I will introduce how we can add Python packages.
References
If you want to install PyCharm as your IDE, you can refer to: PyCharm Installation Tutorial, A famous Python IDE
Interpreter
Python is a dynamic programming language, what we need is an Interpreter but not a Compiler.
In PyCharm, every project we created will have its virtual environment in the folder «venv«. There will be a newly established Interpreter, and there is nothing in it except the basic package.
The advantage of such a pure environment is that there is little conflict between the packages.
Click the gear button in the upper right corner and select Add.
On the left, there are a variety of optional configurations, remote connections, virtual environments, conda environment establishment, and even WSL and Docker.
pip is a tool of the Python management suite, which is very convenient to use in command line.
The above is the default usage method, if you want to adjust, you can also directly set the pip of Python3 to pip.
In PyCharm, we actually have a graphical interface to download the kit. (Of course, if you are accustomed to command line, there is actually a command line below that can be used, and the downloaded package will be installed directly in the virtual environment of the current project)
We pay attention to the two buttons «+» and «-» on the right.
You can see that there are already many Packages in my current project. If you want to remove a package, just select it and press the «-» on the right.
Then think about it the other way around, the «+» sign is to install the package, that is, there is no need to enter the pip command from the Command Line, and the system will automatically install it for us.
We will see this screen, this screen will list all packages that can be installed, and the search box above allows us to actively search for the package we want.
If there is a specific version, for example, you don’t want to update some packages to the latest package (sometimes the latest version is not stable), you can also use the Specify version next to it:
Choose the package and version you want.
After selecting it, press «Install Package» and it will automatically install it for us.
Packages
Packages in Python are some libraries that others have developed for us, so that we can directly import them into our programs without «Reinventing the wheel«.
PyCharm will kindly remind you that the package like my chatterbot has been underlined, which means that there is no such package in my environment.
So I installed the ChatterBot package in the virtual environment of my current project in accordance with the teaching in pip just now. (By the way, ChatterBot also needs to install chatterbot-corpus to run smoothly)
You can see that my PyCharm has no red bottom line warning.
This is an official sample code, you can find it at https://pypi.org/project/ChatterBot/.
Run the code. In my case, I need to press Ctrl + Shift + F10 to execute it directly. My friend told me that it can be changed, but I haven’t tested it.
We can see that ChatterBot executes normally; it has trained quite a bit.
Package installation issues
You might encounter a problem when installing a Python package in the project settings or in the Python Package tool window. Eventually, most of the issues are out of IDE control as PyCharm uses the pip package manager to perform the actual installation.
This article provides troubleshooting tips and covers some typical cases.
Install a package using the Terminal
The most viable troubleshooting action is to try installing the problematic package on the selected Python interpreter using the terminal. If you get an identical error message, then the problem is not in the IDE and you should review the rationales and typical cases, or search for a solution on the Internet.
Install a package on a virtual environment
To check the path of the currently selected Python interpreter that you were trying to install a package on, press Ctrl+Alt+S and go to Project:
Expand the list of the project interpreters and scroll it down, then select the Show All item.
Locate the target interpreter and press .
Copy or memorize the path of the virtual environment and close the dialogs.
Open the terminal and run the following commands:
Install a package on a Conda environment
Open the terminal and run the following commands:
Как правильно устанавливать библиотеки в PyCharm?
VolodinAS
Новичок
Через командную строку я установил нужные мне библиотеки.
Команды:
То есть, через IDLE всё работает.
Запускаю PyCharm, вставляю этот же код:
1\AppData\Local\Temp\tmpttixcb_z:
Error in sitecustomize; set PYTHONVERBOSE for traceback:
SyntaxError: (unicode error) ‘utf-8’ codec can’t decode byte 0xef in position 0: invalid continuation byte (sitecustomize.py, line 7)
Running from numpy source directory.
setup.py:480: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
run_build = parse_setuppy_commands()
Cythonizing sources
Error in sitecustomize; set PYTHONVERBOSE for traceback:
SyntaxError: (unicode error) ‘utf-8’ codec can’t decode byte 0xef in position 0: invalid continuation byte (sitecustomize.py, line 7)
Processing numpy/random\_bounded_integers.pxd.in
Processing numpy/random\bit_generator.pyx
Traceback (most recent call last):
File «C:\Users\VolodinAS\AppData\Local\Temp\pycharm-packaging\numpy\tools\cythonize.py», line 59, in process_pyx
from Cython.Compiler.Version import version as cython_version
ModuleNotFoundError: No module named ‘Cython’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File «C:\Users\VolodinAS\AppData\Local\Temp\pycharm-packaging\numpy\tools\cythonize.py», line 235, in
main()
File «C:\Users\VolodinAS\AppData\Local\Temp\pycharm-packaging\numpy\tools\cythonize.py», line 231, in main
find_process_files(root_dir)
File «C:\Users\VolodinAS\AppData\Local\Temp\pycharm-packaging\numpy\tools\cythonize.py», line 222, in find_process_files
process(root_dir, fromfile, tofile, function, hash_db)
File «C:\Users\VolodinAS\AppData\Local\Temp\pycharm-packaging\numpy\tools\cythonize.py», line 188, in process
processor_function(fromfile, tofile)
File «C:\Users\VolodinAS\AppData\Local\Temp\pycharm-packaging\numpy\tools\cythonize.py», line 64, in process_pyx
raise OSError(‘Cython needs to be installed in Python as a module’)
OSError: Cython needs to be installed in Python as a module
Traceback (most recent call last):
File «D:\DOCUMENTS\ПРОГРАММИРОВАНИЕ\PYTHON\PROJECTS\PYCHARM\me2safeautocracker\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\pep517\_in_process.py», line 207, in
main()
File «D:\DOCUMENTS\ПРОГРАММИРОВАНИЕ\PYTHON\PROJECTS\PYCHARM\me2safeautocracker\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\pep517\_in_process.py», line 197, in main
json_out[‘return_val’] = hook(**hook_input[‘kwargs’])
File «D:\DOCUMENTS\ПРОГРАММИРОВАНИЕ\PYTHON\PROJECTS\PYCHARM\me2safeautocracker\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\pep517\_in_process.py», line 69, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File «D:\DOCUMENTS\ПРОГРАММИРОВАНИЕ\PYTHON\PROJECTS\PYCHARM\me2safeautocracker\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\build_meta.py», line 140, in prepare_metadata_for_build_wheel
File «D:\DOCUMENTS\ПРОГРАММИРОВАНИЕ\PYTHON\PROJECTS\PYCHARM\me2safeautocracker\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\build_meta.py», line 210, in run_setup
File «D:\DOCUMENTS\ПРОГРАММИРОВАНИЕ\PYTHON\PROJECTS\PYCHARM\me2safeautocracker\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\build_meta.py», line 126, in run_setup
File «setup.py», line 508, in
setup_package()
File «setup.py», line 488, in setup_package
generate_cython()
File «setup.py», line 285, in generate_cython
raise RuntimeError(«Running cythonize failed!»)
RuntimeError: Running cythonize failed!
Command «D:\DOCUMENTS\ПРОГРАММИРОВАНИЕ\PYTHON\PROJECTS\PYCHARM\me2safeautocracker\venv\Scripts\python.exe D:\DOCUMENTS\ПРОГРАММИРОВАНИЕ\PYTHON\PROJECTS\PYCHARM\me2safeautocracker\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\pep517\_in_process.py prepare_metadata_for_build_wheel C:\Users\VOLODI
1\AppData\Local\Temp\tmpttixcb_z» failed with error code 1 in C:\Users\VolodinAS\AppData\Local\Temp\pycharm-packaging\numpy
Помогите, пожалуйста, решить проблему. Пытался гуглить, но так и не нашел нужного решения. Не понимаю, PyCharm не использует ранее установленные библиотеки?
How do I install an older version of Pip in Pycharm when it keeps failing?
Ok, so I’m having some trouble importing tweepy and textblob in Pycharm.
Before getting these errors I installed both textblob and tweepy using the following commands:
Which seemed to work fine. When I go into the Python3 shell and run:
I’m able to enter a shell and those packages import correctly.
When I started writing my code in Pycharm, that’s when the issue occurs, after the first 2 import statements as follows:
I get the following errors:
I’m getting the following errors:
I’ve done extensive research on Google and Stack Overflow and came to a conclusion that it’s because of pip (at least I think but please correct me if I’m wrong). I tried installing an older version of pip in Pycharm by going to the Preferences > adding the package > pip but getting the following error:
In this post it says that the «main» method is deprecated in pip 10.0.1, which is the version I’m running but it won’t even let me install an older version, so I’m not sure what to do at this point.
I’m also running Python 3.6.1 if that helps. Would love to get better at troubleshooting and resolving errors! Any help would be great.
EDIT Here’s the full stack trace error when trying to install an older version of pip.
EDIT Still troubleshooting the issue and reading through this post, someone may find it helpful.
Pycharm cann’t find the packages or modules installed with pip on windows
Pycharm doesn’t sync with the pip packages though i have added the path in environment variable. The following elements will clear the topic:
already installed sklearn package:
pycharm can’t find that package:
environment variable:
4 Answers 4
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
The thing is that pycharm creates all of your projects inside a virtual environment. So the packages that you installed outside the virtual environment(global site packages) does not get inherited in to your project. There is a simple solution for that. When you create a pycharm project, make sure to check the «inherit global-site packages» checkbox as shown here.Then you’ll be able to import all the packages to your virtual environment, provided they have been installed in your computer.
Alternatively you can install all the packages separately using «pip install» in the pycharm terminal. If the package has been installed outside the virtual environment, pip will use cached files instead of downloading the package again.
Источники информации:
- http://www.jetbrains.com/help/pycharm/package-installation-issues.html
- http://itfy.org/threads/kak-pravilno-ustanavlivat-biblioteki-v-pycharm.1741/
- http://stackoverflow.com/questions/50474051/how-do-i-install-an-older-version-of-pip-in-pycharm-when-it-keeps-failing
- http://stackoverflow.com/questions/51292729/pycharm-cannt-find-the-packages-or-modules-installed-with-pip-on-windows