I am trying to use the os package with PyCharm. When I follow the IDE's instructions, it doesn't appear on the list.
Why is it? And how else can I install it?
The Managing interpreter packages dialogue in PyCharm is used for installing packages from a repository, by default from pypi, see Available Packages.
The os module itself is part of The Python Standard Library and is already included in the Python interpreter that you have to create before any additional packages can be added to that interpreter.
Related
I am using the cloudscraper python library, installed from the Pycharm UI.
Therefore, I am using the main version of this package.
I would like to try to use the dev version of this package, that can be downloaded through github from the relative branch (https://github.com/VeNoMouS/cloudscraper/tree/dev). In order to install this dev package, I have to run python setup.py install.
Is there a way to keep both versions of this module? How can I install the dev package directly from the UI?
Python does not handle having multiple versions of the same library installed. See for example this related question.
Indeed, the solution is to modify the files for one of the version to give it a different name (for example cloudscraper-dev).
Or you could have two different virtual env, one for each version, but it requires to switch from one to the other.
I have installed Spyder ide on my Mac machine. I already had python installed on my system and I had installed several libraries using pip install (like pandas, sklearn etc). Now when I try to import them in Spyder, they don't work. From python shell, I imported those libraries and added that path to PYTHONPATH in Spyder. But it is still not working. It seems it is searching in the /Applications/Spyder.app/Contents/Resources/ folder. But why wouldn't adding the existing python library path work? Can someone tell me what I am missing?
I have a Pycharm project where I have copied two github projects (download zip and copy paste into project). My problem is that I cannot access the from main, which is located at root.
For some unknown reason from . syntax only shows me files/folders I have created myself.
I'm trying to access build module where there is a class TFNET which I want to import
from darkflow-master.darkflow.net.build import TFNET
Downloading directories like this isn't how you'd typically include external dependencies in a python project.
A more conventional approaches would be ot install the project using pip, it looks like darkflow gives information on how to do this.
Alternatively, just ensure the libraries are in your PYTHONPATH, it looks like pycharm has a way to do this: PyCharm and PYTHONPATH
Reading between the lines, it sounds like you have downloaded two libraries from github, and copied them into your project.
Python needs to know where to find source files.
If you want do it this way, you need to tell your python environment where to find the new sources. Pycharm looks after python environments while you are in python.
Please see https://www.jetbrains.com/help/pycharm/configuring-folders-within-a-content-root.html
but this won't tell python outside of Pycharm where to find your library source.
pip is most likely the answer. pip can install globally or inside python virtual environments, in either case, it puts the library code in a location python is expecting to find it.
On this point, please learn about python virtual environments. These are self-contained python mini-worlds. In a venv, you can run a specific version of python with specific packages. Pycharm works well with them, it is easy to set up virtual envs with pycharm. When you are 'inside' a venv, pip will install into the venv, therefore not touching your system python or the python of any other projects.
Also, pip normally installs from an official repository (pypi) but you can tell it to use a git repository as the source of your install. Normally people who write libraries send their mature versions to pypi so it is unusual to fetch from a git repository, but if you want the very latest version, or if the author has not published the library, it's an option.
Note that pip doesn't work with any arbitrary python code. It must be set up to be seen by pip as a python package.
I used to work with windows when I install a non basic python package with the cmd, but I dont know how to do it on mac, this packaged cant use pip to install on the terminal
It really depends a lot on the specific package. The options can be different, let me present you some:
You can simply add the source files (if they are not properly packaged) to your project and import them
In the same scenario, if the script is not packaged, you can check if there is a way to install it (read the docs). A common way to do it is by having a script in root called setup.py. Try to see if there is a setup script or read the docs to see if there is a way to install it
Check if the package can not be installed with another general package management (you mentioned you use a mac so check with homebrew)
Another possible package management tool for Python is Anaconda, check that one too
Hope this helps!
It is stated in Python documentation here that:
By default, the libraries are searched in prefix/lib/pythonversion and exec_prefix/lib/pythonversion, where prefix and exec_prefix are installation-dependent directories, both defaulting to /usr/local.
But when I looked into my /usr/local directory, what I found was a folder named python2.7. I did install python3.5 not python2.7 on my device (MacBook mid 2012).
You could use sys module to find that.
import sys
print sys.path
Ouput like:
['', '/usr/local/lib/python2.7/dist-packages/mccabe-0.3.1-py2.7.egg', ...
Mac comes with a default Python 2.7 installation. Your installation did not remove python2.7. Probably also the reason why the system libraries are not under usr/local.
You never state how you attempted to install Python 3.5 onto your MacBook, depending on the installation options you used while building the Python source (or the bundle you downloaded) the install location could be different from the defaults. If you provide further details on your installation method, it will be easier to answer all aspects of your question.
As far as I can tell, Apple does not use the installation defaults to provide Python with OSX. On my OSX El Capitan machine, I can see the system Python library at /System/Library/Frameworks/Python.framework/Versions/2.7 and the binary at /usr/bin/python (Python 2.7.x comes preinstalled for all recent versions of OSX).
It looks like the easiest way to get Python 3.5 on Mac is to use MacPython which will install alongside the system version of Python (as you should not alter the default system version of Python or risk breaking OSX). It installs some helper applications into your Finder's Applications directory and installs the library files to /System/Library/Frameworks/Python.framework/Versions/3.5. Since you will have more then one version of Python installed, you would also need to put some effort into making sure your scripts are using the proper version.
If you have a /usr/local/python2.7 directory, that sounds like something that was previously installed by a user. If I remember correctly, OSX does not normally use /usr/local for system software.
Hope that helps