What directory are Python packages installed in?[MAC] - python

I downloaded pycharm and python 3.8, but everytime I try to pip install it goes to some hidden opt/ directory. When i type python --version in the terminal, it says 2.7. I suppose I need to get better with the command line but not sure what to do.
I'd GREATLY appreciate any help on this. Been browsing similar questions for hours and nothing helps.

I think Pycharm by default uses a virtual environment with new projects. Have you tried using the terminal in Pycharm itself? Also, check your installations, you may have multiple Python installations causing the issue.

Related

problem with pycharm interperter and installing packages

I have a problem with installing packages in my pycharm project.
Until today everything worked perfectly, I could install packages and everything worked.
I didn't change anything but now everytime I try to install new package I get an error
pycharm message 1
pycharm message 2
But I do have pip installed in python interpreter
interpreter packages
I'm trying to understand what is the problem and how to fix it.
I'm not sure if this is the problem, but the interpreter is python 3.7 and the weird thing is when I'm checking the version on my cmd it's 3.8.3 but when I checked on Windows's apps it showed python 3.7.3
python version from cmd
Is there a reason it happened just randomly after it worked perfectly in the last couple of weeks I worked on the program?
Maybe it's because i updated the pip?
You can try few things
Running same command in terminal. If it doesn't work then please locate your pip.exe which is generally in the Scripts folder right next to python.exe. Make sure the path/to/folder is in environment variables
Reset project settings. Try deleting .idea directory in your project. This folder is created by pycharm to save settings. Open the project folder again in pycharm and set the interpreter.
Did you try to install directly with pip in the terminal ? If it doesn't work maybe you should reinstall it

Pycharm runtime: No Python at dir\that\doesnt\exist

I had Anaconda installed as well as Python3 and this was causing some conflicts. I removed Anaconda and ensured my PATH variables all point to the Python3 install at C:\Users\me\AppData\Local\Programs\Python\Python38-32
I have opened a project in PyCharm and set the python interpreter to that very path: no venv in case it was causing problems.
However, when CTRL+SHIFT+F10 to run it states No Python at 'C:\Users\me\Anaconda3\python.exe'
I have googled this for the past two hours and all I'm finding is "you haven't installed Python" or "set up the PyCharm interpreter to point to the python executable" which I have done.
I have even reinstalled Pycharm.
Please can someone suggest what I am doing wrong? There is no sign of Anaconda in the system or in the PyCharm terminal interpreter/project interpreter Thanks.
Edit:
Forgot to mention, in the Project > Python Interpreter settings I can see the interpreter and all the packages just fine. On the face of it: Everything is working fine. But run-time is giving me the anaconda install dir error.
Try restarting pycharm once...if not your System..Comment here if it doesn't solve the issue.
I don't know what caused this problem but it resolved itself. Sorry I cannot offer any insights.

Importing module to VS code

im very new in programming and i learn Python.
I'm coding on mac btw.
I'd like to know how can i import some modules in VS code.
For exemple, if i want to use the speedtest module i have to download it (what i did) and then import it to my code. But it never worked and i always have the error no module etc.
I used pip to install each package, i have them on my computer but i really don't know to import them on VS code. Even with the terminal of the IDE.
I know it must be something very common for u guys but i will help me a lot.
Thx
Quick Summary
This might not be an issue with VS Code.
Problem: The folder to which pip3 installs your packages is not on your $PATH.
Fix: Go to /Applications/Python 3.8 in Finder, and run the Update Shell Profile.command script. Also, if you are using pip install <package>, instead of pip3 install <package> that might be your problem.
Details
Your Mac looks for installed packages in several different folders on your Mac. The list of folders it searches is stored in an environment variable called $PATH. Paths like /Library/Frameworks/Python.framework/Versions/3.8/bin should be in the $PATH environment variable, since that's where pip3 installs all packages.
Most probably you have multiple versions of python on your computer.
You have to select your python interpreter for which you have installed those packages using pip to do this you'll have to click on the python version you see in the bottom and select the correct interpreter from the list:
You can also find more information within the VSCode docs.

PyCharm always thows this error on creating new project and interpreter(virtual env) is missing for the project

I have got a problem with pycharm. I reinstalled everything(system python, anaconda, pycharm) since I thought it was conflicting with Anaconda. Finally, I completely got rid of Anaconda and still Pycharm throws the following error whenever I create a new project.
Unable to create process using 'C:\Users\Ritanshu Singh\AppData\Local\Programs\Python\Python37\python.exe
"C:\Program Files\JetBrains\PyCharm Community Edition
2018.3.2\helpers\packaging_tool.py" list'
Also the project(virtual env) interpreter is missing every time I create a new project(My actual system python is installed and works well, I have tried and run a raw python text file) and I can't run the python code. I googled but it shows no results.
I figured out that it has a problem to create virtual environment interpreter but I don't know why? The error code is above listed.
There is a very good documentation available for configuring the python interpreter in Pycharm: https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html and
https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html
Please verify that you follow these steps before starting the Pycharm.
Do not import config.
Check the user permission which starts the Pycharm(Administrative).
Add path variable for python in windows.
install and configure the pip that will help you to download the package while setting up the interpreter.
I found that from Python version 3.3+, the built-in venv module is used, instead of the third-party virtualenv utility. It is written on PyCharm Official Page on this link: https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html

Invalid Python SDK Error while using Python 3.4 on PyCharm

When I switch my PyCharm to use Python 3.4.3 and I am getting the error:
Invalid Python SDK
Also PyCharm does not automatically find the Python 3.4 interpreter for me, even though it is on the desired path /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4. See the screenshot:
Despite this the interpreter does work. I am able to get correct output as expected, but code completion related to Python 3.4 is not working.
E.g. print("hello world!) still shows an error on the editor, but the console shows the correct output.
This also happened to me. I renamed a repository and then my virtual environment got stuck in the old path.
I grepped all configuration files and could not find any reference to the old one.
What finally solved the problem was to clear caches with the option File > Invalidate Caches / Restart...:
I had the same issue.
Try to comment/remove the PYTHONPATH variable in your ~/.bash_profile
#export PYTHONPATH=/usr/local/lib/python2.7/site-packages/
If it does not help it also may be useful to look in the idea.log for the errors:
/Users/username/Library/Logs/PyCharm40/idea.log
I had the following errors:
Your PYTHONPATH points to a site-packages dir for Python 2.x but you are running Python 3.x!
PYTHONPATH is currently: "/usr/local/lib/python2.7/site-packages/"
You should `unset PYTHONPATH` to fix this.
I go the same error message in Windows version of PyCharm after I re-installed Python (3.5) on a different location. The problem was that most of my existing virtual environments registered in PyCharm were still referencing the old installation of Python.
I resolved it by deleting these existing virtual environments and creating a new one. If deleting existing interpreters (in virtual environment) is not an option, you should be able to modify them instead in File | Settings | Project Interpreter
I got the same issue, when I updated Python (3.x) version via Home brew in MacOS.
Above answers didn't work for me. But with those, I realize that, it's an issue with linking the directories. I deleted ~/.virtualenvs folder and recreated all virtual envs.
$ ls -a ~/.virtualenvs
local-dev wdias-dev
$ rm -rf ~/.virtualenvs
$ which python3
/usr/local/bin/python3
$ mkvirtualenv local-dev --python=/usr/local/bin/python3
$ mkvirtualenv wdias-dev --python=/usr/local/bin/python3
Open the PyCharm again, and it works fine.
I couldn't get anything to work, so I cloned my conda env (see how), called it something else, and then set it in PyCharm to the new one.
For me, changing the paths in ~\venv\pyvenv.cfg made PyCharm recognize the new environment after bringing my projects to a new PC.
I had the same issue in Windows10. I was so frustrated, beacause everything seems looked OK. I've added PYTHONPATH, I've restarted Pycharm and deleted old virtualenv folders and created new... It did't work.
And at the end I have just opened Pycharm in an administrator mode and it works!
When creating a new project my interpreter was set to python 2.7 so I had to change that to python3 and everything works like a charm
I got the same problem with Pop OS 21.04 and Pycharm installed via Flatpack. So i remove it and installed via Snap and started working again.
I ended up having to install Python as an admin and make sure it installed to the C:\Program Files\Python310 folder. I think The option was to make sure it installed for all users. If I installed it under for user's appdata it wouldn't work.
Once I did that I was able to point pycharm to the C:\Program Files\Python310\ for the interpreter. Pretty annoying but finally got it working
I've solved it too. Uninstalled python 3.10, installed python 3.9. Changed the python interpreter to 3.9 through pycharm setting. Created a new virtual environment.

Categories