Trying to install psycopg2 in PyCharm [duplicate] - python

This question already has answers here:
Why isn't PyCharm's autocomplete working for libraries I install?
(2 answers)
Closed 7 years ago.
I have been trying to install psycopg2 in PyCharm, but I keep running into this error:
>>> pip install psycopg2
File "<input>", line 1
pip install psycopg2
^
SyntaxError: invalid syntax
I've already managed to install psycopg2 in a virtualenv outside of PyCharm. However, PyCharm doesn't recognize that installation, and it seems that I have to install it separately from inside PyCharm. As a result when I run the project in PyCharm I get this error: ImportError: No module named 'psycopg2'. I'm a beginner to PyCharm--and, frankly, to Python development--so any help would be greatly appreciated.

Given your use of '>>>', it appears that you are trying to install psycopg2 from within Python. Exit the Python shell and run the command.
If you are in IPython, you can prepend your command with an exclamation to run it as a command instead of as Python code:
In[1]: !pip install psycopg2

Try
$ pip install psycopg2==2.4.5
or
$ pip install http://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.4.tar.gz

Related

I am trying to install pygame using pycharm terminal but I get this error [duplicate]

This question already has answers here:
Unable to install Pygame using pip
(27 answers)
Closed last month.
I was trying to install pygame module using pycharm's terminal by typing "pip install pygame" but I am getting this errorinstallation error and yes I have tried running pycharm with admin perms and stuff but it did not work, if you can help then ty!
I just tried to use pygame by typing in my .py file "import pygame" but it say "no module called pygame" and I was simply trying to get a blank window
just upgraded Python to latest version updated pip by using,
pip install --upgrade pip
after that simply run
pip install pygame
Make sure you are using the correct version of python and pygame that both are compatible with each other.
Seems like you don't have admin privilege. Try to open the command prompt with Run as administrator mode or pip install numpy --user

matplotlib error in notebook :No module named 'matplotlib' [duplicate]

This question already has answers here:
jupyter notebook import error: no module named 'matplotlib'
(8 answers)
Closed 1 year ago.
when I import matplotlib in my jupyter notebook it dose not work and this is its error:
enter image description here
can anyone help me what is wrong in my code?
enter image description hereTry these things on your Anaconda Prompt terminal:
pip -V <- The version of pip will be displayed, if it is successfully installed on your system. Then we will try to upgrade it.
pip install --upgrade pip <- do this to upgrade your pip, if it is already upgraded then it will show it.
pip install matplotlib <- then write this command if still doesn't work let me know in the comments
have you even installed the lib?
you can install it with
python -m pip install -U matplotlib

pip install pyodbc is not working on python [duplicate]

This question already has answers here:
Why does "pip install" inside Python raise a SyntaxError?
(7 answers)
Closed 2 years ago.
I installed Python on my Windows 10 computer
when I try to run my python code
I get error
ModuleNotFoundError: No module named 'pyodbc'
I checked multiple questions here and the solution is to pip pyodbc
I tried that
pip install pyodbc
but i get error
SyntaxError: invalid syntax
I checked similar propblems here and it seems that pip is not installed.
I unistalled and reinstalled python from python.org and still same issue!
any solution?
Edit
I did as suggested to try from command prompt
but still same error
I installed Python with ticking the option to include environment variables option.
Edit 2 :
I think the problem was that I was trying to install from witthin python.
I misunderstood the answers, I have to run pip as an application outside of python. to allocate pop.exe and then do pip install.
You are trying to install the package from python interpreter (IDLE) which is wrong. You should only import package from IDLE terminal (python session) which IDLE has access to.
Try this link to install the package --> https://pip.pypa.io/en/latest/installing/
You would run pip from a shell, not from the IDLE. However, pyodbc requires the Microsoft ODBC Driver. More information about installing the pyodbc module can be seen in this guide. This Stack Overflow answer can also help.
Normally, you run pip from a shell, not from a Python interactive session.
C:\PATHTOPYTHON\python.exe pip install <<SOMEPACKAGE>>
See the following thread, if you want to install from within a Python interactive session.

Trying to install python module 'num2words' but getting following issue [duplicate]

This question already has answers here:
pip install failing with: OSError: [Errno 13] Permission denied on directory
(9 answers)
Closed 2 years ago.
In my 64 bit windows machine, I'd installed pip 20.0.2 successfully. Then I tried to install numwords using the following command but got errors.
pip install num2words
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
I'm sorry as the above screen shot not much clear.
Thanks in advance.
pip3 install num2words
You get the error is because it's trying to user older version of python.
Got the solution just adding --user switch with the command.
pip install num2words --user

How do I run pip on python for windows? [duplicate]

This question already has answers here:
Why does "pip install" inside Python raise a SyntaxError?
(7 answers)
Closed 7 years ago.
I've just installed python 3.5, ran Python 3.5 (32-bit) and typed
pip
and received the message:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
pip
NameError: name 'pip' is not defined
I don't see any scripts directories in my path, but I found pip.py in C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\Scripts.
I selected the option to "Add python to environment variables" during installation, but it doesn't seem to have done anything.
I googled this and got this guide, which says that earlier versions need to add some path names. I don't have a C:\Python... directory so I tried adding the Scripts folder from above, same result.
How do I install python so that it actually works (ie. I can run pip, install modules, etc.)?
Maybe you'd like try run pip in Python shell like this:
>>> import pip
>>> pip.main(['install', 'requests'])
This will install requests package using pip.
Because pip is a module in standard library, but it isn't a built-in function(or module), so you need import it.
Other way, you should run pip in system shell(cmd. If pip is in path).
I have a Mac, but luckily this should work the same way:
pip is a command-line thing. You don't run it in python.
For example, on my Mac, I just say:
$pip install somelib
pretty easy!
First go to the pip documentation if not install before:
http://pip.readthedocs.org/en/stable/installing/
and follow the install pip which is first download get-pip.py from
https://bootstrap.pypa.io/get-pip.py
Then run the following (which may require administrator access):
python get-pip.py

Categories

Resources