Pycharm doesnt reslove package dependencies - python

I installed a pycharm application and did configure interpreter. After i installed spark-nlp package via pip inside pycharm, and tried to run programm, it showed that it missing dependecy in form of pyspark package. When I installed pyspark it complained about bunch of packages that are being missing. Shouldn't venv resolve all requirements automatically?

For this to work "pip" should be associated with the Python interpreter you have specified in Pycharm.
Can you check if the interpreter specified in Pycharm and "pip" on the terminal are pointing to same virtualenv which was created?
I believe "pip" on pycharm-terminal is different and not pointing to virtualenv used by Pyharm.

Related

How does PyCharm find libraries installed with pip

I'm using PyCharm and also installing dependencies with pip I dont know how to make PyCharm to get this new dependencies that I install and are in the folder {project_base}/env/lib/python3.9
If I go there I can see the libraries installed, but PyCharm is not able to seen it, and allow me to use it in the code.
I've seen in the preference the Python Interpreter section, but I need to use pip, since I'm documenting the package to install with pip for other users.
Any idea how to point my PyCharm to my env/lib/ folder?
Regards
When you choose Python Interpreter, PyCharm will automatically pick up libraries available on that Python installation.
Make sure PyCharm uses the Python Interpreter that has its libraries installed in env/lib/python3.9 and then you should see available libraries on the interpreter configuration screen.
If you install libraries with pip e.g. env/bin/python -m pip install mylib they will become automatically available to PyCharm, because PyCharm and pip will use the same Python installation to manage these libraries.

Python not recognizing newly installed or some already satisfied modules

I have noticed that when I install new modules using pip install example, it installs correctly but when I try importing it in a script it says: ModuleNotFoundError: No module named 'example'. To get the modules working I have to copy the module's folder to the directory of my script. Before this started happening I had installed some modules which also work now so I'm a bit confused.
I'm guessing that there's something wrong with some PATH but I'm not really sure. How can I fix this?
Edit: I'm almost 100% sure that these problems started happening when I installed Anaconda. I have made sure Anaconda's folder is added to PATH but I still have the same issue.
With Anaconda, you would benefit from installing new packages by conda install example instead of using pip.
However, it is likely that you have installed another copy of Python that comes with Anaconda, and you should check which Python you are using by typing python -V in your command prompt or checking where it is installed (for Windows machines, check here). You might have installed the package to use with one version of Python, but your system directed you to the other one.
I have uninstalled my standalone Python distribution after installing Anaconda, so my default version of Python is the version that comes with Anaconda.

Missing required dependencies ['numpy'] for anaconda ver5.3.1 on pycharm

I just installed anaconda ver5.3.1 which uses python 3.7.
I encountered the following error;
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
I have upgraded numpy, pandas to the latest version using conda but the same error appears. To fix this problem, I have to downgrade to an older anaconda version which uses python 3.6
I am using Windows 10.
EDIT: I just discovered this problem is more related to pycharm than anaconda. I got this error while running pycharm in debug mode. However, when I run the same python script in Anaconda prompt console, there is no error.
What are some possible pycharm settings I should check to fix this problem? Are there ways to configure pycharm to output more verbose error messages?
It's a known issue in PyCharm https://youtrack.jetbrains.com/issue/PY-32366
For a workaround you can define the correct PATH in a run configuration in PyCharm (get the value by activating the conda env in the terminal and echo %PATH%).
Your pycharm created a new environment for your project I suspect. Maybe it copied across the anaconda python.exe but not all the global packages.
In pycharm you can go to the project properties where you can see a list of all the packages available, and add additional packages. Here you can install Numpy.
File --> Settings --> Project: --> Project Interpreter

Anaconda/Python/VSCode: vscode editor doesn't recognize installed packages

I'm trying to use VS Code for python in an Anaconda environment. I have (after some googling and travail) gotten it using my custom environment. However, pylint and the editor don't recognize the installed netifaces in the environment.
The environment (billh) is being loaded:
The errors from python are shown here:
Oddly, importing from ipython running in the built-in terminal does work:
This was newly installed today, via Anaconda. Here's the version info
It isn't that the extension can't find the netifaces package, it's that Pylint can't. Make sure that the Pylint you are having the extension run for you is installed into the same conda environment that you are running from (e.g. make sure you didn't set python.linting.pylintPath to something outside of your conda environment). Also make sure that ipython is from the same environment as well (e.g. you are using a conda environment and launched the terminal with the Python: Create Terminal command).

Issues setting up Virtualenv and Virtualenvwrapper

I'm trying to install virtualenv and virtualenvwrapper so that I can do some django work.
I'm not exactly sure where the issue is stemming from. I currently have installed Jupyter Notebook and installed a lot of python files though it (python 3+ I believe), so when I did pip install virtualevnwrapper, the location of the shell file was in C:/Users/'Andy Renz'/Anaconda3/Scripts/virtualenvwrapper.sh. I account for this in changing by .bashrc file, by including:
export WORKON_HOME=$HOME/.virtualenvs
source C:/Users/'Andy Renz'/Anaconda3/Scripts/virtualenvwrapper.sh
When I run source ~/.bashrc in my shell, I get the following:
bash: /usr/bin/python: No such file or directory
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could no import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and the PATH is
set properly.
I think this means python isn't where it is supposed to be. Virtualenv references python 2+ I believe which leads me to believe my python 2 is somewhere odd. I do have it, not downloaded from Jupyter. How do I account for this and proceed forward?
The issue is you're trying to install the default virtualenvwrapper (for Linux) on a Windows machine. That's why it's trying to get Python from /usr/bin/python, a directory that does not exist in Windows.
Try virtualenvwrapper-win from https://pypi.python.org/pypi/virtualenvwrapper-win
Python is somehow either not installed or installed at different path maybe /usr/local/bin. Use which python or whereis python to check if python is indeed installed and path of installation. Then you can create a softlink to the python executable in your /usr/bin directory.

Categories