Conda package cannot be installed into the PyCharm virtual environment? - python

The attempt to install the conda package from File-->Settings-->Python Interpreter becomes unsuccessful. The following was the output
The message from PyCharm is
ERROR: Could not find a version that satisfies the requirement menuinst (from conda) (from versions: none)
try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at '<UserName>\Pycharm\pythonProject\venv\Scripts\python.exe'.
The output of
<UserName>\PyCharm\pythonProject\venv\Scripts\python.exe -m pip --version
is pip 20.2.4. The pip version in PyCharm interpreter settings is also pip 20.2.4
When I first tried to import numpy by just typing import numpy as np , PyCharm was not successful in installing numpy and gave the message to install using pip from the terminal, installing from the terminal was not successful either. Then Numpy was installed from the Python Interpreter Settings at File-->Settings. Afterwards, before getting NumPy installed, PyCharm even became unable to detect the import statement and to offer to install NumPy
How would Scientific mode be enabled for the current project given that the conda interpreter is not installed?.
How to get the conda package(interpreter) installed from within PyCharm
What is the defect that prevented PYcharm from detecting the import statement in the editor
and giving the message "No module named numpy" with the offer to install NumPy.
What is the reason causing the pip error?

Related

Unable to import package 'pdfrw'

Did pip install pdfrw, uninstalled and reinstalled, restarted my laptop, but still unable to import the specified package as it returns error: No module named 'pdfrw'.
https://pypi.org/project/pdfrw/#pdfrw-philosophy
Any advice is appreciated.
Update: Tried installing by cmd, I'm using Jupyter Notebook as IDE :)
You have to make sure that the Python that you are using with Jupyter Notebook is the same that the one for which you are installing that package. If you have several Python interpreters installed or if you installed Ananconda to use Jupyter, you have to take care of which pip are you invoking from CMD.
If you are using Jupyter from Ananconda, try to install the package using conda.
conda install pdfrw
Another thing that you can do is open a Command Prompt and type:
where python
you will get the path to the interpreters that you have installed. In my case I get:
>>> C:\Windows\system32>where python
C:\Python39\python.exe
C:\Python38\python.exe
>>> C:\Windows\system32>where pip
C:\Python39\Scripts\pip.exe
C:\Python38\Scripts\pip.exe
Then you can use a concrete interpreter to call pip, in my case I will do:
C:\Python39\python.exe -m pip install pdfrw
After the installation finish, invoke the same interpreter you use to call pip:
C:\Python39\python.exe
Then try to import pdfrw. If you can import it, then the problem is that you are using a different interpreter in Jupyter Notebook.

Can`t import pygame to VScode despite having it installed

I'm using pip 21.2.4 and python 3.9.7
I'm pretty sure I have pip installed since if I run pip --version in the terminal it gives me pip 21.2.4 from C:\Users\rohaan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pip (python 3.9)
If I run pip install pygame in the terminal I get Requirement already satisfied: pygame in c:\users\rohaan\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (2.0.1)
Despite the requirement being satisfied when I import pygame I get ModuleNotFoundError: No module named 'pygame'
Does anybody know how to fix this?
It looks like you are not using the python interpreter which you have installed the pygame package.
You can execute this code to verify which python interpreter you are using:
import sys
print(sys.executable)
Then you can switch the python interpreter to which you have installed the packages or you need to activate the environment before you want to install the package in order to install the package to the right place.
This means you have multiple versions of python installed on your device, one has the module and the other tries to run the file, go to the control panel and check it out.

Using pip in the standalone Spyder on MacOS

As the Anaconda Distribution of Spyder has some typing latency issues on macOS Big Sur, I've gone ahead and downloaded the standalone distribution. However, when trying to install packages with pip I get the error message:
pip install numpy
/Applications/Spyder.app/Contents/MacOS/python: No module named pip
Note: you may need to restart the kernel to use updated packages.
(I know that NumPy is already installed - this just serves as an example). I have Anaconda installed, and there pip works fine. How do I install it for the specific Standalone Distribution?
I solved this problem using the Command Prompt and typing pip install -U spyder. If you don't have the "standalone version" of Python, just install it to have access to this command.
After that, you can simply open Spyder typing in the Command Prompt spyder.

Can't use Anaconda properly due to package installation error

I'm using Python 3.8 with pyCharm generally but for some Machine Learning tutorial I wanted to use Anaconda Spyder 4.1.2. So when I write in default windows cmd
C:\Users\Ege>python --version
Python 3.8.2
when I write in anaconda prompt:
(base) C:\Users\Ege>python --version
Python 3.7.7
This is the version of my base(root) environment. I searched and found Anaconda supports 3.8 for environments but not for base yet. Therefore I cannot upgrade it to 3.8. Now the problem comes:
When I try to use numpy in Spyder it says there is no module imported called numpy. I went and check my anaconda base environment and yes there is no numpy package. I opened the conda prompt and I wrote
pip3 install numpy
It says:
Requirement already satisfied: numpy in c:\python38\lib\site-packages (1.18.1)
But goddamit you don't allow me to use python38.
Some of you can say okay go make a new environment with python38 and use the packages. However I want to install the packages to base environment. Any ideas ?
Instead of usin pip one should use conda install. the names are not always equal to each other which means sometimes pip install thisPackage is not equal to conda install thisPackage therefore one should search before installing that package to their environment.

Attempting to install Python PIL module fails with "Non-zero exit code"

I really don't get why Python is so difficult to get up and running properly.
Anyway, I've just fresh installed Python 3.7 and PyCharm. I want to get the Python Imaging Library working within my project, but when I try to install it using PyCharm I get the following error:
pip install PIL
Non-zero exit code (1)
Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at 'C:\Users\Jake\AppData\Local\Programs\Python\Python37-32\python.exe'.
Command output:
Collecting PIL
Could not find a version that satisfies the requirement PIL (from versions: )
No matching distribution found for PIL
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
I've attempted to run python -m pip install --upgrade pip from a CMD prompt, but I then get this error:
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
I just tried to install NumPy using the exact same method for PIL and Numpy installed without any issues whatsoever. This leads me to think that maybe PIL isn't supported for Python 3.7?
Can someone explain to me what the issue is here and help me with importing modules into my PyCharm project?
PIL is not maintained anymore. You can use Pillow instead, a more active fork of PIL.
pip install Pillow

Categories

Resources