This question already has answers here:
How do I use installed packages in PyCharm?
(14 answers)
Closed 1 year ago.
I am extremely new to python and have been learning basics via DataCamp.
I downloaded Python 3 and PyCharm to use it with and all was going okay with me replicating what i was learning in DataCamp into PyCharm.
I am now trying to install packages into PyCharm and the standard way (demonstrated in Data Camp) isnt working
I have opened a new .pynfile and typed 'pip install Scrapy' but everything is underlined red (below). When i hover over the 'install' part it says that the 'Statement seems to have no effect'
pip install Scrapy with red squiggly lines
Am i doing this wrong.
Secondly, I have tried to install the Scrapy package by going to settings and have faced a bunch of different errors. i finally downloaded most of what i think i needed, including the 'twisted' package (i had to download this manually). But PyCharm again isnt letting me install this package.
I read online it needed to be downloaded using this method python -m pip install C:\Users%USER%\Downloads\Twisted-17.9.0-cp36-cp36m-win32.whl but again this didnt work. I even opened up the Python.exe and ran this, replacing the file name with the correct path and it errored saying invalid syntax.
Please help !
Updated to add pic of cmd error
pic of error in cmd]2
Updated to add PyCharm Error
command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit code 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\%USER%\AppData\Local\Programs\Python\Python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\%USER%\\AppData\\Local\\Temp\\pip-install-20efmwoj\\twisted_efc7d2a70fcd40639034d265eeb0e045\\setup.py'"'"'; __file__='"'"'C:\\Users\\%USER%\\AppData\\Local\\Temp\\pip-install-20efmwoj\\twisted_efc7d2a70fcd40639034d265eeb0e045\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\%USER%\AppData\Local\Temp\pip-record-abp6_zhs\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\%USER%\AppData\Roaming\Python\Python39\Include\Twisted' Check the logs for full command output.
PyCharm uses his own package manager. Open File->Settings->Project->Python Interpreter and search the "+" button on the right. In the new window that just appeared, you can search and install any package you want.
PIP is Python's package installer. You can use PIP by running it from the command line (CMD, so outside of PyCharm).
Opening the CMD:
Windows button + R (on windows)
Enter cmd and then press enter. Now you can execute the following command:
pip install scrapy
which will install the scrapy package
Probably PyCharm can immediately use it, but restarting PyCharm performs magic!
As I stated in a comment, you need to add python to PATH. You can do this following this tutorial: https://www.makeuseof.com/python-windows-path/#:~:text=How%20to%20Manually%20Add%20Python%20to%20the%20Windows,the%20PATH%20With%20the%20System%20Variables%20Option.%20. Then run pip install scrapy in the command prompt and that will work. Make sure you restart command prompt.
Related
I am trying to install the spacy python library for python 3.4 on windows 7. i keep getting install errors (the important-looking error messages are below).
I installed it for 2.7, but I can't seem to install it for 3.4.
I tried doing:
pip3.4 install -U spacy
But it does not seem to work. Does anybody have any ideas? I'm trying to avoid crazy system surgery. There must be some simple way to do this.
Warning: The nvcc binary could not be located in your $PATH. For GPU capability, either add it to your path, or set $CUDA_HOME
warning: no files found matching '*.cpp' under directory 'include'
warning: no files found matching 'buildbot.json'
***********************************************************
WARNING: One of the following dependencies is unresolved:
ctypes >=1.0.1
readline >=1.7.1
***********************************************************
error: Unable to find vcvarsall.bat
Cleaning up...
Command C:\Python34\python.exe -c "import setuptools, tokenize;file='C:\Users\joe\AppData\Local\Temp\pip_build_joe\spacy\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record C:\Users\joe\AppData\Local\Temp\pip-sxqy1vof-record\install-record.txt --single-version-externally-managed --compile failed with error code 1 in C:\Users\joe\AppData\Local\Temp\pip_build_joe\spacy
Storing debug log for failure in C:\Users\joe\pip\pip.log
In order for python to detect it you must place it in the following directory.
C:\Python27\
or where ever python is located.
I have got a problem with installing Scipy on my Python 2.7 , Windows in IPython.
When I enter "pip install scipy", I have one first error message:
"Failed building wheel for scipy" and then at the end
"
Command "c:\python27\python.exe -c "import setuptools,tokenize;__file__='c:\\us
ers\\admini~1\\appdata\\local\\temp\\pip-build-e3yebj\\scipy\\setup.py';exec(com
pile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __f
ile__, 'exec'))" install --record c:\users\admini~1\appdata\local\temp\pip-mwhxl
d-record\install-record.txt --single-version-externally-managed --compile" faile
d with error code 1 in c:\users\admini~1\appdata\local\temp\pip-build-e3yebj\sci
py
"
I do not know how to solve that problem, thanks if you have any ideas
You can download the wheel from this web site:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
You need to pick the right one. So, for
scipy‑0.19.0‑cp34‑cp34m‑win32.whl
cp34 means it will work with python 3.4
make sure you go with this one in your case:
scipy‑0.19.0‑cp27‑cp27m‑win32.whl and whatever your windows is (32 or 64).
once downloaded, go to the command line and put:
python -m pip install scipy‑0.19.0‑cp27‑cp27m‑win32.whl (making sure it is sitting in the right directory).
That should solve the problem.
I also met this problem and I then installed a Python distribution like Anaconda instead!
I'm very new to Python and programming world and has been going along with tutorials from newcoder.io This Here! I have been doing as per the instructions but when I try to install NumPy I get an error.
"
error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27
Command "C:\Users\HP.virtualenvs\DataVizProj\Scripts\python.exe -c "import setuptools, tokenize;file='c:\users
\appdata\local\temp\pip-build-lsj5sj\numpy\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).re
.replace('\r\n', '\n'), file, 'exec'))" install --record c:\users\hp\appdata\local\temp\pip-6jei4k-record\instal
cord.txt --single-version-externally-managed --compile --install-headers C:\Users\HP.virtualenvs\DataVizProj\includ
te\python2.7" failed with error code 1 in c:\users\hp\appdata\local\temp\pip-build-lsj5sj\numpy
"
But that's not enough, I tried to install VCForPython27.msi from the given link. But still, gets the same error.
Please Help!
I recommend installing the Anaconda distribution of Python. It contains more packages than you can dream of, including numpy of course: http://continuum.io/downloads
The installation is as straightforward as installing the usual Python, no matter what OS you are on.
A good solution is to download the wheel file which match your Python version here:unofficial python binaries
And then go to the folder where the .whl file is present using the command prompt and unpack the wheel file xxxxx.whl with:
>python -m pip install xxxxx.whl
This will install the library in the Lib\site-packages folder, you can check it afterwards.
I am trying to install fatiando, a geophysical modelling package for Python.
I have a Mac with OS X v10.9.5. I am getting all the dependencies for Fatiando (via Anaconda) by following the recommended installation suggested on the package site. I have Xcode installed.
I get a list of warnings and a final error message:
fatiando/gravmag/_polyprism.c:349:10: fatal error: 'omp.h' file not found
#include "omp.h"
^
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "//anaconda/bin/python -c "import setuptools, tokenize;__file__='/var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-QFjo6d-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-CY4vyX-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-QFjo6d-build
Macintosh-5:fatiando matteoniccoli$
The full Terminal output (1100+ lines) can be found here.
I already contacted the developers, this does not seem to be a Fatiando issue.
Any suggestions?
UPDATE, March 15
When I first posted this I did not have Xcode, then I downloaded the latest Xcode from Apple store. Tried again, got the same message. Then I read this and downloaded gcc from here, and installed directly. When I type on terminal: gcc --version, I get this: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
After that, though, I still get similar messages. Following another stackoverflow lead, I tried to install setuptools from here
using curl https://bootstrap.pypa.io/ez_setup.py -o - | python
Now I get a different error (at the end again of a long output) when I try to install fatiando:
fatiando/gravmag/_polyprism.c:349:10: fatal error: 'omp.h' file not found
#include "omp.h"
^
1 warning and 1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Command "//anaconda/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-build-m1ieVO/fatiando/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-9wI6Z7-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-build-m1ieVO/fatiando
Someone from a forum asked me by email:
Re Fatiando, did you install Xcode command line tools? Eg see this
http://railsapps.github.io/xcode-command-line-tools.html
But when I try to verify tI’ve successfully installed Xcode Command Line Tools as suggested there, I get this, so I assume it was not the issue:
-bash: /Library/Developer/CommandLineTools: is a directory
UPDATE MARCH 16
Tried solution suggested by Leo Uieda.
pip install --upgrade https://github.com/fatiando/fatiando/archive/kill-omp.zip went without a problem, but
pip install --upgrade https://github.com/fatiando/fatiando/archive/master.zip gets me back at square 1:
...
...
fatiando/gravmag/_polyprism.c:349:10: fatal error: 'omp.h' file not found
#include "omp.h"
^
1 warning and 1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Rolling back uninstall of fatiando
This is a very common problem with the Fatiando install, specially on Windows and Mac. OpenMP was introduced in PR 106 for the fatiando.gravmag forward modeling modules. It was easy to implement (just replace a range(ndata) with a prange(ndata)) and was resulting in 1.5-2x speedup over sequential execution. Also, the parallel execution was automatic. So it seemed like a good trade-off at the time ("Just install an extra dependency? What could go wrong?").
The problems began when the Anaconda gcc and the default Mac gcc didn't come with OpenMP. So Windows users had to install an extra dependency (in a very specific order, like a satanic ritual) and Mac users had to fend for themselves.
OpenMP and compiled Cython modules are being removed from Fatiando (#169) in preference of multiprocessing and numba. This would make it a pure Python package (no compilation necessary) and most of the install issues should be resolved.
In the mean time, PR 177 removes the OpenMP requirement from the Cython modules. This should fix your current install problems. To get the changes right away, you can install the version from the kill-omp branch by running:
pip install --upgrade https://github.com/fatiando/fatiando/archive/kill-omp.zip
If the above command doesn't work, it means that the pull request has been merged into the main branch of the project (master). If that's the case, you can install the latest version from the master branch:
pip install --upgrade https://github.com/fatiando/fatiando/archive/master.zip
These changes will be included in the future v0.4 release. Hope this fixes your problem.
(It would be useful to know which version of gcc you are using.)
gcc did not ship with OpenMP prior to v4.9.
See this answer could help you update gcc it using xcode.
I got that issue when i try installing pylint on windows with pip, and i really have no idea from where it comes from.
C:\Python33\Scripts>pip.exe install pylint
Downloading/unpacking pylint
Getting page https://pypi.python.org/simple/pylint/
URLs to search for versions for pylint:
* https://pypi.python.org/simple/pylint/
Analyzing links from page https://pypi.python.org/simple/pylint/
...
byte-compiling C:\Python33\Lib\site-packages\pylint\utils.py to utils.cpython-33.pyc
byte-compiling C:\Python33\Lib\site-packages\pylint\__init__.py to __init__.cpython-33.pyc
byte-compiling C:\Python33\Lib\site-packages\pylint\__pkginfo__.py to __pkginfo__.cpython-33.pyc
error: The system cannot find the file specified
running 2to3 on C:\Python33\Lib\site-packages\pylint\test
----------------------------------------
Cleaning up...
Removing temporary dir c:\windows\temp\pip_build_abrow198...
Command C:\Python33\python.exe -c "import setuptools;__file__='c:\\windows\\temp\\pip_build_abrow198\\pylint\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\windows\temp\pip-cq0pam-record\install-record.txt --single-version-externally-managed failed with error code 1 in c:\windows\temp\pip_build_abrow198\pylint
Looks like there's an error in the setup scripts for both Pylint and its dependency logilab-common. I encounter the error when building with pip install pylint or python setup.py install.
The error generally looks like this, and occurs right after .pyc files are byte-compiled:
error: The system cannot find the file specified
running 2to3 on C:\Python33\Lib\site-packages\pylint\test
Simply making sure that 2to3.py is available on PATH doesn't seem to be sufficient; 2to3 itself will run, but Pylint won't install.
I just spent a bit trying to get this working, and found two promising suggestions:
First option, create a custom bat file so that 2to3 is effectively on your PATH (see SO thread, issue tracker). I managed to get 2to3 running as a bare command in both PowerShell and CMD, but couldn't get Pylint to install. Someone else might have more luck with this.
Second option, install different versions of Pylint and logilab-common which invoke 2to3 through distutils instead of on the command line (see unmerged pull request). This worked immediately for me.
BitBucket lists that pull request as "open" since October. I don't know when it might be merged, or how long after that changes might be live on PyPI.