Why does Cython not want to work ? I've pip installed it and when I try to import it, it just won't work.
I'm using MacOS Version 10.12.6 (16G29)
Here's even a screenshot:
This is possible if you have multiple versions of Python installed try:
python3.7 -m pip install cython
use which pip3 to check where it was installing the package previously
Update: OP used python3.7, if you have a different alias or a different version, you should use that instead. This is obviously installation dependent.
Related
I have installed tqdm using pip install tqdm
but I still got an error that ModuleNotFoundError: No module named 'tqdm',
how can I fix this?
my code looks like this from tqdm import tqdm
Here are some options I can advise:
Check that you have tdqm with pip show tdqm
Check that you're using the correct virtual environment.
You can try uninstall and then reinstall it again.
If you use a virtual environment, ensure the correct environment is activated.
Also, you might need to use pip3 instead of pip, as in pip3 install tqdm.
Finally, check if you have multiple versions of python installed. For Windows/Mac/Linux. If you have multiple versions of python. Delete unused versions.
I've installed a module named rauth through terminal with pip3 install rauth command but when I import the module and run the code on Visual Studio Code with python3 interpreter, it gives ModuleNotFoundError: No module named 'rauth' error. But it is indeed installed and I can use it in Anaconda. The package file is stored here.
/Users/puffedricecracker/anaconda3/lib/python3.7/site-packages/rauth
And it seems like all my pip installed packages are stored in that path, but those are imported outside Anaconda with no problem. Tried several other commands as google search suggested.
• pip install instead of pip3 install
• python -m pip install
• python3 -m pip install
Let me know if there is any other information needed to be specified.
this is due to the module is installed into site-packages in Anaconda but not Visual Studio. Can you check if the module exists in Visual Studio folder? Another way to test it is to open Python IDLE and run the import, it should also return an error.
I don't know if this could be an universal solution but there was a way to set where to install a package using pip.
In python shell, find where your python modules usually go. It seemed like most of pip installed packages were installed in the second path so I chose that.
>>> import re
>>> print(re.__file__)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/re.py
>>> import sqlalchemy
>>> print(sqlalchemy.__file__)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sqlalchemy/__init__.py
Uninstall the package using pip uninstall packagename
Reinstall with a path name.
pip install packagename -t /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
(In fact, just copy pasting package files (in my case, they were rauth, rauth-0.7.3.dist-info) from anaconda package path in the post worked.)
I install the python library named Python.NET package using pip install pythonnet, clr module is installed and imported, installation of qsharp module independently is done successfully but importing qsharp is displaying error.
Can anyone tell me why it is giving error while importing?
I am using spyder to run python code and anaconda for installation.
The process for installing qsharp is a little convoluted as you have to "install" it more than once.
The first install would be something like:
dotnet tool install -g Microsoft.Quantum.IQSharp
dotnet iqsharp install
The second install (that trips some of us up) is you then have to also:
pip install qsharp
After that it should import correctly in Python.
Try
pip3 install qsharp
Then
python3 x.py
You have to be careful from the version of Python that you're using , if you have many versions on your computer delete them and let only the most recent one , however Q# is installed in 2 steps :
Installing package :
pip install qshart
Then installing kernel ( you'll need to install dotnet ) :
dotnet tool install -g Microsoft.Quantum.IQSharp
dotnet iqsharp install
I was using VScode and getting this error very frequently. I realized that i needed to change the environment to the one in which qsharp was installed.. as it needed to be installed in different environment than base.
Also you will need to get the terminal to the directory where your code is.
Just posted as I did struggle with this early on.
I can download python 2.7.12 from python.org, and all python versions from 2.7.9 onwards are supposed to come with pip, but after installing it, using pip in the terminal does not work.
I am on macOS.
Have I installed pip, and if I have, how do I use it?
Here you have informations about pip:
https://packaging.python.org/installing/
normally python from python.org come with pip, maybe you should just update...
to update from terminal:
pip install -U pip setuptools
After when you need to install package, for example numpy, just do in a terminal:
pip install numpy
more informations here :
https://pip.pypa.io/en/stable/reference/pip_install/
you can also use conda install from anaconda as an alternative of pip :
http://conda.pydata.org/docs/get-started.html
Multiple instances of Python can coexist on your machine. Thus you could have installed Python 2.7.12 yet, when you call Python from terminal, you may be calling an older version.
To know which version you are using, type which python in terminal and look at its path. Then from Python in terminal, type
import sys
print(sys.version)
to get the exact version.
As Dadep says, I would recommend using conda to isolate your invironments if you have to play with multiple Python interpreters. Further conda simplifies 3rd party package installation process beyond doubt.
I am trying to edit some code that uses python-magic but I get an Import Error: No module called magic. Before I looked around the Internet and found advise on installing python-magic using pip which I did. I installed python-magic using pip install python-magic and also did pip install libarchive-c successfully.
when I try to do the import on the python shell. I am able to successfully as below;
But when I try to run code that uses this import statement I get an import error for missing magic module as below;
If anyone knows what is happening. Please help.
You have installed magic for Python 2.7, but Diffoscope uses Python 3 and explicitly recommends the package python3-magic in the repositories, which can be installed with sudo apt-get install python3-magic. Modules installed for Python 2.7 are not necessarily shared with Python 3, so you may need to install both versions if you need it for 2.7 as well.
On Ubuntu, you can run Python 3 with python3 and access Python 3's pip installation with pip3 to ensure that you are using the correct version.