PyCharm 2018.1.3 pro / Python 3.6.1 / Module: neo4j-driver 1.5.3
The strange thing is that if I trying to import neo4j.v1 using script editor in PyCharm and run it I'm getting error:
Traceback (most recent call last): File "C:/experiment/Cypher.py",
line 1, in from neo4j.v1 import GraphDatabase ModuleNotFoundError: No
module named 'neo4j'
Process finished with exit code 1
But this script works just fine if I call it using Windows PowerShell environment using simple command prompt:
> python C:/experiment/Cypher.py
So, I think that something is wrong with settings or with PyCharm. What should I do to solve this problem?
From pycharm,
goto settings -> project Interpreter
Click on + button on top right corner and you will get pop-up window of Available packages. Then search for neo4j python package.
Then click on Install package to install the package.
neo4j.v1 is not a default python module, it is not automatically installed when you install python.
To install neo4j.v1 Follow the instructions here.
Its possible to install it directly from pycharm, as other answers have pointed out, but its better to download from the official source to make sure all related dependencies and packages are properly installed.
Related
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'
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
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.
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"
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 :)
So I am new in Python. I downloaded Anaconda (and Homebrew) and using Terminal on my Mac I confirmed that, say, Numpy is installed:
pip install numpy
to get as a result
Requirement already satisfied: numpy in ./anaconda/lib/python3.6/site-packages
Then opening Python within Terminal I can indeed import the package. The story is not the same once I open IDLE. So when I open it and try to import, say, Numpy I get the following message:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import numpy
ModuleNotFoundError: No module named 'numpy'
I guess there is something I do not know, I assume it is a common rookie problem. Can you help me with this?
Since your IDLE is using Python 3 you should use
pip3 install numpy
to get it installed for the correct Python. If you want to use your default installed Python (2.x) instead, IDLE is located at /usr/bin/. From your terminal you can open it with
/usr/bin/idle
this should have the numpy you installed with pip install numpy
See when you are working with Anaconda it creates its own virtual environment.
Now, If you are new in python on MAC then you might not familiar with Virtual Environment.
I suggest you to download python from the official website www.python.org
or Click here to directly download Python 3.6.2 on your MAC.
Then, Download Pycharm(The Best IDE for Python)
Download the community version for beginner and it is also free.
Pycharm Community Version -> Click Here
And do whatever you want and also must read about Virtualenv
According to me, Pycharm is better then Anaconda's Jupyter Notebook
Wish you good luck and show your creativity in python ! !
Erm... well it appears as though - since you have 2 versions on your computer - that it might be because it imported it into the other file path directory. Now, I've never worked with Mac, but I think if you just specify which pip you want to download from, it might work.
For example, on Windows:
C:\Python34\Scripts\pip.exe install numpy
or if you were doing it for 3.6, you would follow the path to the folder, find pip and install. So, I suggest to install the normal IDLE before any other platform built upon it just because it is easier to import modules and is not as bad to break like yours has.
There can be two issues -
You are using python 2 as a kernel for IDLE, since numpy is installed for python3.6. This will raise an error.
The issue is with anaconda's configuration with IDLE. Anaconda installs numpy in ./anaconda/lib/python3.6/site-packages. If IDLE uses systems default python instead of anaconda's. You will not be able to import numpy.
You can try running this snippet -
import sys
print('\n'.join(sys.path))
to track the location of python exactly.
One of the workaround that I can think of is -
create a virtual environment using anaconda. Something like
conda create -n py352 python=3.5.2 anaconda
and then fire IDLE from your terminal. Though I am not entirely sure, if this works for mac. If it doesn't, let me know the output of -
import sys
print('\n'.join(sys.path))
I'm just getting started with PyCharm, python, and OpenCV, and I'm trying to set up my environment. I've installed all the necessary packages and I import OpenCV like so:
import cv2
However, this does not autocomplete and shows warnings that the method may be missing when called, BUT if I import like so:
import cv2.cv2
autocomplete does work, but running produces the following error:
Traceback (most recent call last):
File "C:/Users/dunnj/PycharmProjects/TransformApps/transformapps/blackwhite.py", line 1, in <module>
import cv2.cv2 as cv2
AttributeError: 'module' object has no attribute 'cv2'
My Configuration:
PyCharm 2021.2.3 on macOS 11.6
Python 3.9.7 running in a Virtual Environment(VE)
opencv-python 4.5.4.58 installed into the VE via pip using the PyCharm Terminal window
Steps that worked for me to get autocompletion working:
tldr: Update python interpreter settings to point to <full path to venv>/lib/python3.9/site-packages/cv2
In preferences, Select Python Interpreter
Click the setting icon ( gear on right of box that display your Python Interpreter and select Show All
A list of all your configured Interpreters is show with your current interpreter already hi-lighted.
With your interpreter still highlighted, click the Icon that shows a folder and subfolder at the top. Tool tip should say "Show Paths for Selected Interpreter.
Click the + button and add the following path:
<full path to the venv>/lib/python3.9/site-packages/cv2
The .../python3.9... will be different if you are using a different Python Version.
Click Ok until you are back to the main IDE window.
This has worked in three different Virtual environments for me so far. For two of those, I had to restart the IDE for the completions to show up. The remaining one did not require a restart and worked immediately.
Credit to ingolemo from r/learnpython. I was stuck on this for ages and it drove me mad so I'm here sharing.
My OpenCV was installed by using the wrapper opencv-python package
The sys.modules hacking that that module is doing is the source of the
problem. Pycharm doesn't exactly import modules in order to know
what's inside of them, so messing with the imports dynamically like
that confuses pycharm greatly. It's not pycharm's fault, the
opencv-python maintainer should have used a star import rather than
that messy import hack. You should be able to work around the problem
using the technique you stumbled upon. All you have to do is catch and
ignore the error under normal operation:
import cv2
# this is just to unconfuse pycharm
try:
from cv2 import cv2
except ImportError:
pass
just execute the following commands in your project working environment.
pip uninstall opencv-python
pip install opencv-python==4.5.4.60
The proposed import solution did not work for me.
I had exactly this problem with OpenCV 4.2.0 compiled from sources, installed in my Conda environment and PyCharm 2020.1.
I solved this way:
Select project interpreter
Click on the settings button next to it and then clicking on the Show paths for selected interpreter
added the directory containing the cv2 library (in my case in the Conda Python library path - e.g. miniconda3/lib/python3.7/site-packages/cv2/python-3.7). In general check the site-packages/cv2/python-X.X directory)
Following Workaround 2 from the JetBrains issue tracker (https://youtrack.jetbrains.com/issue/PY-54649) helped me:
In PyCharm open from menue FILE - SETTINGS
Go to PROJECT:<your_project_name> and select PYTHON INTERPRETER
Click on the gear symbol next to the interpreter path and select SHOW ALL.
Make sure the correct interpreter is selected.
Click on that icon that looks like a folder tree (on the top)
Click on the "+" icon
Select the folder where the opencv package is located
normally (if you installed it via package manager) you will find it in:
<your_project_path>\venv\Lib\site-packages\cv2
Click OK (twice)
Wait for updating skeletons
Installing Jedi solved this problem for me.
You can use pip install jedi in terminal
You can find more info about jedi here: https://pypi.org/project/jedi/
i had the same problem.
i used
import cv2 as cv2
and after that both importing meth
try
try:
import cv2.__init__ as cv2
except ImportError:
pass
If you are using virtualenv, then mark the virtualenv directory as excluded in your project structure in Pycharm project settings.
Encountered this before.
find "cv2.cp38-win_amd64.pyd" in "Lib\site-packages\cv2" path.
Copy it to "DLLs" path.
Work for system python and anaconda environments(need to do this in conda envs path)
PS.
"site-packages" path can be found by "pip --version"
"DLLs" path is located at "Lib\site-packages....\DLLs"
From IDLE, I tried to run a script with a newly installed scrapy 1.0.3.
I'm using a script from a friend whom it worked for (but on Windows, I'm on a Mac).
From the import of scrapy on the first line, I get this error when running the program:
ImportError: No module named twisted.persisted.styles
The whole script, if it's helpful, points to this:
Traceback (most recent call last):
File "/Users/eliasfong/tutorial/tutorial/spiders/medspider.py", line 1, in <module>
import scrapy
File "/Library/Python/2.7/site-packages/scrapy/__init__.py", line 27, in <module>
from . import _monkeypatches
File "/Library/Python/2.7/site-packages/scrapy/_monkeypatches.py", line 20, in <module>
import twisted.persisted.styles # NOQA
ImportError: No module named twisted.persisted.styles
Any suggestions on how to tackle this problem?
Just try to force the update of twisted :
pip install twisted --upgrade
That works for me with python3.4 and Scrapy==1.1.0rc1
Either twisted is installed on your mac (I highly doubt it since it's not a standard library) and for whatever reason the IDE (i'm assuming that's what you mean since you typed "idle") or the terminal you are in doesn't have your updated environment variables, meaning it doesn't understand where your default python libraries are (again I highly doubt it), or you simple do not have twisted installed on your mac. If it's not installed you have a couple of options:
The easiest way to install a python package is through pip.
If that not an option you can try homebrew which is another package manager for macs. It offers an easy way to install packages correctly.
If that still is not an option for you or you simply don't want to attempt that you can download twisted directly from here (the .bz2 since you're on a mac), click on it and it should unzip it for you. Then just run setup.py and it should install it in the correct location on your mac.
If that still doesn't work and you have decent knowledge of unix. Use the "locate" command on the terminal and find out where your dist-packages directory is and put the source for twisted in there directly and then attempt to import twisted in your IDE or in the python interpreter to verify that it is installed.
note: If you're still having problems after it is installed trying restarting your IDE or messing with some setting to make sure your IDE has the right environment and python path. Hope that helps!
It could be related to having installed Python without bzip2. I had the same error and this helped me, see the accepted answer here:
Installing Twisted through pip broken on one server
Had this exact thing on FreeBSD. Solution (as root/sudo):
chmod -R go+rX /usr/local/lib/python2.7/site-packages
Some directory permissions weren't set up right on install.
I'm running Pycharm 3.4.1 and i just downloaded the Kivy 1.8.0 for python 2.7 pack for windows.
http://kivy.org/#download
I chose the kivy interpreter as my python interpreter for the project:
C:\Python_Kivy_1.8.0\Python27\python.exe
The problem i'm having is that i can't get my Pycharm to run or recognize Kivy at all. There is no auto-completion when writing code and it can't execute via Pycharm. The only way i can execute the program is by running the python file with the kivy.bat file, and that is anoying to do every time.
When i'm trying to execute the code via pycharm i get the following error:
Traceback (most recent call last):
File "C:/Users/Victor/Dropbox/Private/filewatcher_gui/main.py", line 1, in <module>
import kivy
ImportError: No module named kivy
Process finished with exit code 1
I hope you can help me.
The kivy wiki has some pages on configuring for different ides, including pycharm.
You could also probably install in your existing installation using the (unofficial) prebuilt windows packages here. Make sure to get kivy's dependencies as well if you try this way.